use of com.redhat.jenkins.plugins.ci.CIMessageBuilder in project jms-messaging-plugin by jenkinsci.
the class AmqMessagingPluginIntegrationTest method testSimpleCIEventWithMessagePropertiesAsVariable.
@Test
public void testSimpleCIEventWithMessagePropertiesAsVariable() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
jobA.getBuildersList().add(new Shell("echo CI_TYPE = $CI_TYPE"));
jobA.getBuildersList().add(new Shell("echo TEST_PROP1 = $TEST_PROP1"));
jobA.getBuildersList().add(new Shell("echo TEST_PROP2 = $TEST_PROP2"));
attachTrigger(new CIBuildTrigger(true, Collections.singletonList(getSubscriberProviderData("otopic", "CI_MESSAGE", "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'"))), jobA);
Thread.sleep(1000);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.addProperty(new ParametersDefinitionProperty(new TextParameterDefinition("MESSAGE_PROPERTIES", "CI_STATUS = failed\nTEST_PROP1 = GOT 1\nTEST_PROP2 = GOT 2", "")));
jobB.getBuildersList().add(new CIMessageBuilder(getPublisherProviderData("otopic", MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "${MESSAGE_PROPERTIES}", "")));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
FreeStyleBuild lastBuild = jobA.getLastBuild();
j.assertBuildStatusSuccess(lastBuild);
j.assertLogContains("echo CI_TYPE = code-quality-checks-done", lastBuild);
j.assertLogContains("echo TEST_PROP1 = GOT 1", lastBuild);
j.assertLogContains("echo TEST_PROP2 = GOT 2", lastBuild);
}
use of com.redhat.jenkins.plugins.ci.CIMessageBuilder in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithMultipleTopics.
// TODO restart tests
public void _testSimpleCIEventTriggerWithMultipleTopics() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
attachTrigger(new CIBuildTrigger(false, Arrays.asList(getSubscriberProviderData("topic1", null, null, new MsgCheck("my-topic", "topic1")), getSubscriberProviderData("topic2", null, null, new MsgCheck("my-topic", "topic2")))), jobA);
jobA.getBuildersList().add(new Shell("echo $CI_MESSAGE"));
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getBuildersList().add(new CIMessageBuilder(getPublisherProviderData("topic1", MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, null, "{ \"my-topic\" : \"topic1\" }")));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("topic1", jobA.getLastBuild());
FreeStyleProject jobC = j.createFreeStyleProject();
jobC.getBuildersList().add(new CIMessageBuilder(getPublisherProviderData("topic2", MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, null, "{ \"my-topic\" : \"topic2\" }")));
j.buildAndAssertSuccess(jobC);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("topic2", jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageBuilder in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testEnsureFailedSendingOfMessageFailsBuild.
public void _testEnsureFailedSendingOfMessageFailsBuild() throws Exception {
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getBuildersList().add(new CIMessageBuilder(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", null)));
FreeStyleBuild build = j.buildAndAssertStatus(Result.FAILURE, jobB);
j.assertLogContains("Unhandled exception in perform: ", build);
}
use of com.redhat.jenkins.plugins.ci.CIMessageBuilder in project jms-messaging-plugin by jenkinsci.
the class MessageProviderMigrator method migrateCIMessageBuilders.
@Initializer(after = InitMilestone.JOB_LOADED)
public static void migrateCIMessageBuilders() {
Jenkins instance = Jenkins.get();
if (GlobalCIConfiguration.get().isMigrationInProgress()) {
log.info("isMigrationInProgress - > true | Forcing GlobalCIConfiguration.save()");
GlobalCIConfiguration.get().save();
}
int updatedCount = 0;
log.info("Attempting to migrate all CIMessageBuilders, CIMessageNotifier and CIMessageSubscriberBuilders build/publish steps");
for (BuildableItemWithBuildWrappers item : instance.getItems(BuildableItemWithBuildWrappers.class)) {
Job<?, ?> job = (Job<?, ?>) item;
if (job instanceof Project) {
Project<?, ?> p = (Project<?, ?>) item.asProject();
for (CIMessageBuilder builderObj : p.getBuildersList().getAll(CIMessageBuilder.class)) {
if (updateCIMessageBuilder(p, builderObj)) {
updatedCount++;
}
}
for (CIMessageNotifier notifierObj : p.getPublishersList().getAll(CIMessageNotifier.class)) {
if (updateCIMessageNotifier(p, notifierObj)) {
updatedCount++;
}
}
for (CIMessageSubscriberBuilder builderObj : p.getBuildersList().getAll(CIMessageSubscriberBuilder.class)) {
if (updateCIMessageSubscriberBuilder(p, builderObj)) {
updatedCount++;
}
}
}
if (job instanceof MatrixProject) {
MatrixProject p = (MatrixProject) item.asProject();
for (CIMessageBuilder builderObj : p.getBuildersList().getAll(CIMessageBuilder.class)) {
if (updateCIMessageBuilder(p, builderObj)) {
updatedCount++;
}
}
for (CIMessageNotifier notifierObj : p.getPublishersList().getAll(CIMessageNotifier.class)) {
if (updateCIMessageNotifier(p, notifierObj)) {
updatedCount++;
}
}
for (CIMessageSubscriberBuilder builderObj : p.getBuildersList().getAll(CIMessageSubscriberBuilder.class)) {
if (updateCIMessageSubscriberBuilder(p, builderObj)) {
updatedCount++;
}
}
}
}
log.info("Updated " + updatedCount + " build/publish step(s)");
}
Aggregations