use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testDisabledJobDoesNotGetTriggered.
public void _testDisabledJobDoesNotGetTriggered() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
jobA.getBuildersList().add(new Shell("echo CI_TYPE = $CI_TYPE"));
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'"))), jobA);
jobA.disable();
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", null)));
j.buildAndAssertSuccess(jobB);
jobA.enable();
// Wait for trigger to kick in
Thread.sleep(3000);
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("echo CI_TYPE = code-quality-checks-done", jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithDefaultValue.
public void _testSimpleCIEventTriggerWithDefaultValue() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
jobA.getBuildersList().add(new Shell("echo hello $DEFAULTPARAM"));
jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("CI_MESSAGE", "", ""), new StringParameterDefinition("DEFAULTPARAM", "world", "")));
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, null))), jobA);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, null, null, "Hello World")));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("hello world", jobA.getLastBuild());
FreeStyleBuild build = jobA.scheduleBuild2(0, new ParametersAction(new StringParameterValue("DEFAULTPARAM", "scott", ""))).get();
j.assertBuildStatusSuccess(build);
j.assertLogContains("hello scott", build);
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerHeadersInEnv.
public void _testSimpleCIEventTriggerHeadersInEnv(FreeStyleProject jobB, String expected) throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, "CI_TYPE = 'code-quality-checks-done'"))), jobA);
// We are only checking that this shows up in the console output.
jobA.getBuildersList().add(new Shell("echo $MESSAGE_HEADERS"));
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, null, "some irrelevant content")));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains(expected, jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithTopicOverrideAndVariableTopic.
public void _testSimpleCIEventTriggerWithTopicOverrideAndVariableTopic() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData("org.fedoraproject.my-topic", null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'"))), jobA);
jobA.getBuildersList().add(new Shell("echo CI_TYPE = $CI_TYPE"));
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("MY_TOPIC", "org.fedoraproject.my-topic", "")));
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("$MY_TOPIC", MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", null)));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("echo CI_TYPE = code-quality-checks-done", jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithParamOverride.
public void _testSimpleCIEventTriggerWithParamOverride() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, "CI_TYPE = 'code-quality-checks-done'"))), jobA);
jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("PARAMETER", "bad parameter value", ""), new StringParameterDefinition("status", "unknown status", "")));
jobA.getBuildersList().add(new Shell("echo $PARAMETER"));
jobA.getBuildersList().add(new Shell("echo $CI_MESSAGE"));
jobA.getBuildersList().add(new Shell("echo status::$status"));
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "PARAMETER = my parameter\nstatus=${BUILD_STATUS}\nCOMPOUND = Z${PARAMETER}Z", "This is my content with ${COMPOUND} ${BUILD_STATUS}")));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
FreeStyleBuild lastBuild = jobA.getLastBuild();
j.assertBuildStatusSuccess(lastBuild);
j.assertLogContains("status::SUCCESS", lastBuild);
j.assertLogContains("my parameter", lastBuild);
j.assertLogContains("This is my content with Zmy parameterZ SUCCESS", lastBuild);
}
Aggregations