use of com.redhat.jenkins.plugins.ci.CIBuildTrigger in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerOnPipelineJob.
public void _testSimpleCIEventTriggerOnPipelineJob() throws Exception {
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(null, null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'"))), jobA);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", "Hello World")));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIBuildTrigger in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testVerifyModelUIPersistence.
public void _testVerifyModelUIPersistence() throws Exception {
WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "jobA");
jobA.setDefinition(new CpsFlowDefinition("node('master') {\n echo 'hello world' \n} ", true));
CIBuildTrigger trigger = new CIBuildTrigger(true, Collections.singletonList(getSubscriberProviderData("otopic", "HELLO", null, new MsgCheck(MESSAGE_CHECK_FIELD, MESSAGE_CHECK_VALUE))));
attachTrigger(trigger, jobA);
j.configRoundtrip(jobA);
CIBuildTrigger ciTrigger = jobA.getTriggers().values().stream().filter(t -> t instanceof CIBuildTrigger).map(t -> (CIBuildTrigger) t).findFirst().get();
assertThat(ciTrigger, equalTo(trigger));
WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "job");
job.setDefinition(new CpsFlowDefinition("node('master') {\n def message = sendCIMessage " + " providerName: '" + DEFAULT_PROVIDER_NAME + "', " + " overrides: [topic: 'otopic'], " + " failOnError: true, " + " messageContent: '" + MESSAGE_CHECK_CONTENT + "'}\n", true));
j.buildAndAssertSuccess(job);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIBuildTrigger in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithChoiceParam.
public void _testSimpleCIEventTriggerWithChoiceParam(String properties, String body, String matchString) throws Exception {
WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "foo");
jobA.setDefinition(new CpsFlowDefinition("node('master') {\n echo \"mychoice is $mychoice\"\n}", true));
jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("CI_MESSAGE", "", ""), new StringParameterDefinition("mychoice", "scott\ntom", "")));
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, null))), jobA);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, null, properties, body)));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains(matchString, jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIBuildTrigger in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithTextArea.
public void _testSimpleCIEventTriggerWithTextArea(String body, String matchString) throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
jobA.getBuildersList().add(new Shell("echo CI_MESSAGE = \"$CI_MESSAGE\""));
jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("CI_MESSAGE", "", "")));
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, null))), jobA);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, null, null, body)));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains(matchString, jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIBuildTrigger in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testDisabledWorkflowJobDoesNotGetTriggered.
public void _testDisabledWorkflowJobDoesNotGetTriggered() throws Exception {
WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "jobA");
jobA.setDefinition(new CpsFlowDefinition("echo \"CI_TYPE = ${env.CI_TYPE}\"", true));
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'"))), jobA);
jobA.doDisable();
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", null)));
j.buildAndAssertSuccess(jobB);
Thread.sleep(5000);
assertThat(jobA.getBuilds(), Matchers.iterableWithSize(0));
jobA.doEnable();
Thread.sleep(3000);
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("CI_TYPE = code-quality-checks-done", jobA.getLastBuild());
}
Aggregations