Search in sources :

Example 31 with CIBuildTrigger

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

the class SharedMessagingPluginIntegrationTest method _testJobRename.

public void _testJobRename() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'"))), jobA);
    jobA.getBuildersList().add(new Shell("echo CI_TYPE = $CI_TYPE"));
    Thread.sleep(1000);
    jobA.renameTo("ABC");
    Thread.sleep(3000);
    assertThat("Trigger not subscribed", isSubscribed("ABC"));
}
Also used : Shell(hudson.tasks.Shell) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) FreeStyleProject(hudson.model.FreeStyleProject)

Example 32 with CIBuildTrigger

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

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithRegExpCheck.

public void _testSimpleCIEventTriggerWithRegExpCheck() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, null, new MsgCheck("$.compose.compose_id", "Fedora-Atomic.+")))), jobA);
    jobA.getBuildersList().add(new Shell("echo job ran"));
    jobA.getBuildersList().add(new Shell("echo CI_MESSAGE = $CI_MESSAGE"));
    FreeStyleProject jobB = j.createFreeStyleProject();
    jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, null, null, "{ \"compose\": { \"compose_id\": \"Fedora-Atomic-25-20170105.0\" } }")));
    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)

Example 33 with CIBuildTrigger

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

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithPipelineSendMsg.

public void _testSimpleCIEventTriggerWithPipelineSendMsg() 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);
    WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "job");
    job.setDefinition(new CpsFlowDefinition("node('master') {\n def message = sendCIMessage " + " providerName: '" + DEFAULT_PROVIDER_NAME + "', " + " messageContent: '', " + " messageProperties: 'CI_STATUS = failed'," + " messageType: 'CodeQualityChecksDone'}\n", true));
    j.buildAndAssertSuccess(job);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
}
Also used : Shell(hudson.tasks.Shell) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) FreeStyleProject(hudson.model.FreeStyleProject) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob)

Example 34 with CIBuildTrigger

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

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTrigger.

public void _testSimpleCIEventTrigger() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, 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(null, 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 35 with CIBuildTrigger

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

the class JMSMessagingWorker method trigger.

public void trigger(String jobname, String messageSummary, Map<String, String> params) {
    CIBuildTrigger trigger = findTrigger(jobname);
    if (trigger != null) {
        log.info("Scheduling job '" + jobname + "' based on message:\n" + messageSummary);
        trigger.scheduleBuild(params);
    } else {
        log.log(Level.WARNING, "Unable to find CIBuildTrigger for '" + jobname + "'.");
    }
}
Also used : CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger)

Aggregations

CIBuildTrigger (com.redhat.jenkins.plugins.ci.CIBuildTrigger)35 FreeStyleProject (hudson.model.FreeStyleProject)34 Shell (hudson.tasks.Shell)26 CIMessageNotifier (com.redhat.jenkins.plugins.ci.CIMessageNotifier)24 MsgCheck (com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck)14 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)10 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)10 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)9 StringParameterDefinition (hudson.model.StringParameterDefinition)8 FreeStyleBuild (hudson.model.FreeStyleBuild)6 Test (org.junit.Test)6 CIMessageBuilder (com.redhat.jenkins.plugins.ci.CIMessageBuilder)3 ActiveMQSubscriberProviderData (com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData)3 EnvironmentVariablesNodeProperty (hudson.slaves.EnvironmentVariablesNodeProperty)3 FedmsgRelayContainer (com.redhat.jenkins.plugins.ci.integration.fixtures.FedmsgRelayContainer)2 MessagingProviderOverrides (com.redhat.jenkins.plugins.ci.messaging.MessagingProviderOverrides)2 BooleanParameterDefinition (hudson.model.BooleanParameterDefinition)2 ParametersAction (hudson.model.ParametersAction)2 StringParameterValue (hudson.model.StringParameterValue)2 File (java.io.File)2