Search in sources :

Example 1 with CIBuildTrigger

use of com.redhat.jenkins.plugins.ci.CIBuildTrigger 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);
}
Also used : Shell(hudson.tasks.Shell) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) CIMessageBuilder(com.redhat.jenkins.plugins.ci.CIMessageBuilder) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) TextParameterDefinition(hudson.model.TextParameterDefinition) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test)

Example 2 with CIBuildTrigger

use of com.redhat.jenkins.plugins.ci.CIBuildTrigger 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());
}
Also used : Shell(hudson.tasks.Shell) StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) 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 3 with CIBuildTrigger

use of com.redhat.jenkins.plugins.ci.CIBuildTrigger 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)));
}
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 4 with CIBuildTrigger

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

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithCheck.

public void _testSimpleCIEventTriggerWithCheck() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    jobA.getBuildersList().add(new Shell("echo job ran"));
    attachTrigger(new CIBuildTrigger(false, 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);
    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 5 with CIBuildTrigger

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

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithCheckOnPipelineJob.

public void _testSimpleCIEventTriggerWithCheckOnPipelineJob() throws Exception {
    WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "jobA");
    jobA.setDefinition(new CpsFlowDefinition("node('master') {\n sleep 10\n}", true));
    attachTrigger(new CIBuildTrigger(false, 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);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) MsgCheck(com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck) FreeStyleProject(hudson.model.FreeStyleProject)

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