Search in sources :

Example 26 with CIBuildTrigger

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

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

Example 28 with CIBuildTrigger

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

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

Example 30 with CIBuildTrigger

use of com.redhat.jenkins.plugins.ci.CIBuildTrigger 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);
}
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) FreeStyleBuild(hudson.model.FreeStyleBuild) 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