use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithCheckWithTopicOverrideAndVariableTopic.
public void _testSimpleCIEventTriggerWithCheckWithTopicOverrideAndVariableTopic() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData("org.fedoraproject.my-topic", null, null, new MsgCheck(MESSAGE_CHECK_FIELD, MESSAGE_CHECK_VALUE)))), jobA);
jobA.getBuildersList().add(new Shell("echo job ran"));
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("MY_TOPIC", "org.fedoraproject.my-topic", "")));
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("$MY_TOPIC", null, null, MESSAGE_CHECK_CONTENT)));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("echo job ran", jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventSubscribeWithCheck.
public void _testSimpleCIEventSubscribeWithCheck() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
jobA.getBuildersList().add(new CIMessageSubscriberBuilder(getSubscriberProviderData(null, "HELLP", "", 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(null, null, null, MESSAGE_CHECK_CONTENT)));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("catch me", jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventSubscribeWithNoParamOverride.
public void _testSimpleCIEventSubscribeWithNoParamOverride() throws Exception {
// Job parameters are NOT overridden when the subscribe build step is used.
FreeStyleProject jobA = j.createFreeStyleProject();
jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("PARAMETER", "original parameter value", "")));
jobA.getBuildersList().add(new CIMessageSubscriberBuilder(getSubscriberProviderData(null, "MESSAGE_CONTENT", "CI_TYPE = 'code-quality-checks-done'")));
jobA.getBuildersList().add(new Shell("echo $PARAMETER"));
jobA.getBuildersList().add(new Shell("echo $MESSAGE_CONTENT"));
scheduleAwaitStep(jobA);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "PARAMETER = my parameter", "This is my content")));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("original parameter value", jobA.getLastBuild());
j.assertLogContains("This is my content", jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithCheckNoSquash.
public void _testSimpleCIEventTriggerWithCheckNoSquash() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
jobA.getBuildersList().add(new Shell("sleep 3;"));
attachTrigger(new CIBuildTrigger(true, Collections.singletonList(getSubscriberProviderData(null, null, null, new MsgCheck(MESSAGE_CHECK_FIELD, MESSAGE_CHECK_VALUE)))), jobA);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, null, null, MESSAGE_CHECK_CONTENT)));
j.buildAndAssertSuccess(jobB);
j.buildAndAssertSuccess(jobB);
j.buildAndAssertSuccess(jobB);
j.buildAndAssertSuccess(jobB);
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
assertThat(jobA.getLastBuild().getNumber(), is(equalTo(5)));
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithSelectorWithCheckWithPipelineWaitForMsg.
public void _testSimpleCIEventTriggerWithSelectorWithCheckWithPipelineWaitForMsg() throws Exception {
WorkflowJob wait = j.jenkins.createProject(WorkflowJob.class, "wait");
wait.setDefinition(new CpsFlowDefinition("node('master') {\n def scott = waitForCIMessage providerName: '" + DEFAULT_PROVIDER_NAME + "'," + " selector: \"CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'\"," + " checks: [[field: '" + MESSAGE_CHECK_FIELD + "', expectedValue: '" + MESSAGE_CHECK_VALUE + "']]\n" + "}", true));
scheduleAwaitStep(wait);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", MESSAGE_CHECK_CONTENT)));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(wait.getLastBuild());
j.assertLogContains("catch me", wait.getLastBuild());
FreeStyleProject jobC = j.createFreeStyleProject();
jobC.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", "{\"content\": \"uncaught\"}")));
j.buildAndAssertSuccess(jobC);
// Wait fixed ammount of time to make sure the build does NOT get scheduled
Thread.sleep(3000);
assertThat(wait.getLastBuild().getNumber(), is(equalTo(1)));
}
Aggregations