Search in sources :

Example 16 with CIMessageNotifier

use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerOnPipelineJobWithGlobalEnvVarInTopic.

public void _testSimpleCIEventTriggerOnPipelineJobWithGlobalEnvVarInTopic() throws Exception {
    j.jenkins.getGlobalNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("MY_TOPIC_ID", "MY_UUID")));
    WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "jobA");
    jobA.setDefinition(new CpsFlowDefinition("node('master') {\n sleep 10\n}", true));
    attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData("$MY_TOPIC_ID", null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'"))), jobA);
    FreeStyleProject jobB = j.createFreeStyleProject();
    jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("$MY_TOPIC_ID", MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", "Hello World")));
    j.buildAndAssertSuccess(jobB);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) FreeStyleProject(hudson.model.FreeStyleProject) EnvironmentVariablesNodeProperty(hudson.slaves.EnvironmentVariablesNodeProperty)

Example 17 with CIMessageNotifier

use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithCheckOnPipelineJobWithGlobalEnvVarInTopic.

public void _testSimpleCIEventTriggerWithCheckOnPipelineJobWithGlobalEnvVarInTopic() throws Exception {
    j.jenkins.getGlobalNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("MY_TOPIC_ID", "MY_UUID")));
    WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "jobA");
    jobA.setDefinition(new CpsFlowDefinition("node('master') {\n sleep 10\n}", true));
    attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData("$MY_TOPIC_ID", null, null, new MsgCheck(MESSAGE_CHECK_FIELD, MESSAGE_CHECK_VALUE)))), jobA);
    FreeStyleProject jobB = j.createFreeStyleProject();
    jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("$MY_TOPIC_ID", null, null, MESSAGE_CHECK_CONTENT)));
    j.buildAndAssertSuccess(jobB);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) MsgCheck(com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck) FreeStyleProject(hudson.model.FreeStyleProject) EnvironmentVariablesNodeProperty(hudson.slaves.EnvironmentVariablesNodeProperty)

Example 18 with CIMessageNotifier

use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventSubscribeWithCheckWithTopicOverrideAndVariableTopic.

public void _testSimpleCIEventSubscribeWithCheckWithTopicOverrideAndVariableTopic() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("MY_TOPIC", "my-topic", "")));
    jobA.getBuildersList().add(new CIMessageSubscriberBuilder(getSubscriberProviderData("$MY_TOPIC", "HELLO", null, new MsgCheck(MESSAGE_CHECK_FIELD, MESSAGE_CHECK_VALUE))));
    jobA.getBuildersList().add(new Shell("echo $HELLO"));
    scheduleAwaitStep(jobA);
    FreeStyleProject jobB = j.createFreeStyleProject();
    jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("my-topic", null, null, MESSAGE_CHECK_CONTENT)));
    j.buildAndAssertSuccess(jobB);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
    j.assertLogContains("catch me", jobA.getLastBuild());
}
Also used : Shell(hudson.tasks.Shell) StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) CIMessageSubscriberBuilder(com.redhat.jenkins.plugins.ci.CIMessageSubscriberBuilder) FreeStyleProject(hudson.model.FreeStyleProject) MsgCheck(com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck)

Example 19 with CIMessageNotifier

use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.

the class AmqMessagingPluginWithFailoverIntegrationTest method testSimpleCIEventTrigger.

@Test
public void testSimpleCIEventTrigger() throws Exception {
    ArrayList<FreeStyleProject> jobs = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        FreeStyleProject jobA = j.createFreeStyleProject("receiver" + i);
        jobA.getBuildersList().add(new Shell("echo CI_TYPE = $CI_TYPE"));
        jobA.addTrigger(new CIBuildTrigger(true, Collections.singletonList(new ActiveMQSubscriberProviderData(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'", Collections.emptyList(), "CI_MESSAGE", 60))));
    }
    waitForNoAMQTaskThreads();
    long currentThreadCount = getCurrentAMQThreadCount();
    System.out.println("Current AMQ Thread Count: " + currentThreadCount);
    String previousThreads = printAMQThreads();
    System.out.println(previousThreads);
    FreeStyleProject jobB = j.createFreeStyleProject("sender");
    jobB.getPublishersList().add(new CIMessageNotifier(new ActiveMQPublisherProviderData(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", null, true)));
    j.buildAndAssertSuccess(jobB);
    for (FreeStyleProject job : jobs) {
        FreeStyleBuild lastBuild = job.getLastBuild();
        j.assertBuildStatusSuccess(lastBuild);
        j.assertLogContains("echo CI_TYPE = code-quality-checks-done", lastBuild);
        lastBuild.delete();
    }
    // Now stop AMQ
    System.out.println("Stopping AMQ");
    stopAMQ();
    System.out.println("Waiting 60 secs");
    Thread.sleep(60000);
    // Check for unconnection AMQ threads
    System.out.println(printAMQThreads());
    ensureNoUnconnectedThreads();
    // Now startup
    System.out.println("Starting AMQ");
    startAMQ();
    System.out.println("Waiting 10 secs");
    Thread.sleep(10000);
    waitForNoAMQTaskThreads();
    System.out.println(printAMQThreads());
    ensureNoLeakingThreads(currentThreadCount, previousThreads);
    j.buildAndAssertSuccess(jobB);
    Thread.sleep(1000);
    for (FreeStyleProject job : jobs) {
        FreeStyleBuild lastBuild = job.getLastBuild();
        j.assertBuildStatusSuccess(lastBuild);
        j.assertLogContains("echo CI_TYPE = code-quality-checks-done", lastBuild);
        lastBuild.delete();
    }
    System.out.println(printAMQThreads());
    System.out.println("Waiting 10 secs");
    Thread.sleep(10000);
    waitForNoAMQTaskThreads();
}
Also used : Shell(hudson.tasks.Shell) ActiveMQSubscriberProviderData(com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) ActiveMQPublisherProviderData(com.redhat.jenkins.plugins.ci.provider.data.ActiveMQPublisherProviderData) ArrayList(java.util.ArrayList) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test)

Example 20 with CIMessageNotifier

use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.

the class RabbitMQMessagingPluginIntegrationTest method testFedoraMessagingHeaders.

@Test
public void testFedoraMessagingHeaders() throws Exception {
    FreeStyleProject job = j.createFreeStyleProject();
    job.getPublishersList().add(new CIMessageNotifier(new RabbitMQPublisherProviderData("test", null, "", true, true, 20, "schema")));
    FreeStyleBuild lastBuild = j.buildAndAssertSuccess(job);
    j.assertLogContains("fedora_messaging_severity=20, fedora_messaging_schema=schema}", lastBuild);
    j.assertLogContains("{sent_at=", lastBuild);
}
Also used : CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) RabbitMQPublisherProviderData(com.redhat.jenkins.plugins.ci.provider.data.RabbitMQPublisherProviderData) Test(org.junit.Test)

Aggregations

CIMessageNotifier (com.redhat.jenkins.plugins.ci.CIMessageNotifier)35 FreeStyleProject (hudson.model.FreeStyleProject)34 CIBuildTrigger (com.redhat.jenkins.plugins.ci.CIBuildTrigger)23 Shell (hudson.tasks.Shell)23 MsgCheck (com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck)11 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)10 StringParameterDefinition (hudson.model.StringParameterDefinition)10 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)10 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)10 CIMessageSubscriberBuilder (com.redhat.jenkins.plugins.ci.CIMessageSubscriberBuilder)8 FreeStyleBuild (hudson.model.FreeStyleBuild)4 EnvironmentVariablesNodeProperty (hudson.slaves.EnvironmentVariablesNodeProperty)2 Test (org.junit.Test)2 CIMessageBuilder (com.redhat.jenkins.plugins.ci.CIMessageBuilder)1 ActiveMQPublisherProviderData (com.redhat.jenkins.plugins.ci.provider.data.ActiveMQPublisherProviderData)1 ActiveMQSubscriberProviderData (com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData)1 RabbitMQPublisherProviderData (com.redhat.jenkins.plugins.ci.provider.data.RabbitMQPublisherProviderData)1 Initializer (hudson.init.Initializer)1 MatrixProject (hudson.matrix.MatrixProject)1 AbstractProject (hudson.model.AbstractProject)1