Search in sources :

Example 21 with CIMessageNotifier

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

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithTopicOverride.

public void _testSimpleCIEventTriggerWithTopicOverride() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData("otopic", 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.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("otopic", 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());
}
Also used : Shell(hudson.tasks.Shell) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) FreeStyleProject(hudson.model.FreeStyleProject)

Example 22 with CIMessageNotifier

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

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithWildcardInSelector.

public void _testSimpleCIEventTriggerWithWildcardInSelector() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, "compose LIKE '%compose_id\": \"Fedora-Atomic%'"))), jobA);
    jobA.getBuildersList().add(new Shell("echo CI_TYPE = $CI_TYPE"));
    FreeStyleProject jobB = j.createFreeStyleProject();
    jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed\n compose = \"compose_id\": \"Fedora-Atomic-25-20170105.0\"", "")));
    j.buildAndAssertSuccess(jobB);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
    j.assertLogContains("echo CI_TYPE = code-quality-checks-done", jobA.getLastBuild());
}
Also used : Shell(hudson.tasks.Shell) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) FreeStyleProject(hudson.model.FreeStyleProject)

Example 23 with CIMessageNotifier

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

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithBoolParam.

public void _testSimpleCIEventTriggerWithBoolParam(String properties, String body, String matchString) throws Exception {
    WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "foo");
    jobA.setDefinition(new CpsFlowDefinition("node('master') {\n echo \"dryrun is $dryrun, scott is $scott\"\n}", true));
    jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("CI_MESSAGE", "", ""), new BooleanParameterDefinition("dryrun", false, ""), new StringParameterDefinition("scott", "", "")));
    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());
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) 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)

Example 24 with CIMessageNotifier

use of com.redhat.jenkins.plugins.ci.CIMessageNotifier 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)");
}
Also used : Jenkins(jenkins.model.Jenkins) MatrixProject(hudson.matrix.MatrixProject) Project(hudson.model.Project) AbstractProject(hudson.model.AbstractProject) CIMessageBuilder(com.redhat.jenkins.plugins.ci.CIMessageBuilder) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) BuildableItemWithBuildWrappers(hudson.model.BuildableItemWithBuildWrappers) CIMessageSubscriberBuilder(com.redhat.jenkins.plugins.ci.CIMessageSubscriberBuilder) Job(hudson.model.Job) MatrixProject(hudson.matrix.MatrixProject) Initializer(hudson.init.Initializer)

Example 25 with CIMessageNotifier

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

the class SharedMessagingPluginIntegrationTest method _testDisabledJobDoesNotGetTriggeredWithCheck.

public void _testDisabledJobDoesNotGetTriggeredWithCheck() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, null, new MsgCheck(MESSAGE_CHECK_FIELD, MESSAGE_CHECK_VALUE)))), jobA);
    jobA.getBuildersList().add(new Shell("echo job ran"));
    jobA.disable();
    FreeStyleProject jobB = j.createFreeStyleProject();
    jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, null, null, MESSAGE_CHECK_CONTENT)));
    j.buildAndAssertSuccess(jobB);
    Thread.sleep(5000);
    assertThat(jobA.getBuilds(), Matchers.iterableWithSize(0));
    jobA.enable();
    Thread.sleep(3000);
    j.buildAndAssertSuccess(jobB);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
    j.assertLogContains("echo job ran", jobA.getLastBuild());
}
Also used : Shell(hudson.tasks.Shell) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) FreeStyleProject(hudson.model.FreeStyleProject) MsgCheck(com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck)

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