Search in sources :

Example 41 with StringParameterDefinition

use of hudson.model.StringParameterDefinition in project jms-messaging-plugin by jenkinsci.

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithChoiceParam.

public void _testSimpleCIEventTriggerWithChoiceParam(String properties, String body, String matchString) throws Exception {
    WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "foo");
    jobA.setDefinition(new CpsFlowDefinition("node('master') {\n echo \"mychoice is $mychoice\"\n}", true));
    jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("CI_MESSAGE", "", ""), new StringParameterDefinition("mychoice", "scott\ntom", "")));
    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) 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 42 with StringParameterDefinition

use of hudson.model.StringParameterDefinition in project jms-messaging-plugin by jenkinsci.

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithTextArea.

public void _testSimpleCIEventTriggerWithTextArea(String body, String matchString) throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    jobA.getBuildersList().add(new Shell("echo CI_MESSAGE = \"$CI_MESSAGE\""));
    jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("CI_MESSAGE", "", "")));
    attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData(null, null, null))), jobA);
    FreeStyleProject jobB = j.createFreeStyleProject();
    jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData(null, null, null, body)));
    j.buildAndAssertSuccess(jobB);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
    j.assertLogContains(matchString, 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 43 with StringParameterDefinition

use of hudson.model.StringParameterDefinition in project jms-messaging-plugin by jenkinsci.

the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventSubscribeWithCheckWithTopicOverrideAndVariableTopic.

public void _testSimpleCIEventSubscribeWithCheckWithTopicOverrideAndVariableTopic() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("MY_TOPIC", "my-topic", "")));
    jobA.getBuildersList().add(new CIMessageSubscriberBuilder(getSubscriberProviderData("$MY_TOPIC", "HELLO", null, new MsgCheck(MESSAGE_CHECK_FIELD, MESSAGE_CHECK_VALUE))));
    jobA.getBuildersList().add(new Shell("echo $HELLO"));
    scheduleAwaitStep(jobA);
    FreeStyleProject jobB = j.createFreeStyleProject();
    jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("my-topic", null, null, MESSAGE_CHECK_CONTENT)));
    j.buildAndAssertSuccess(jobB);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
    j.assertLogContains("catch me", jobA.getLastBuild());
}
Also used : Shell(hudson.tasks.Shell) StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) CIMessageSubscriberBuilder(com.redhat.jenkins.plugins.ci.CIMessageSubscriberBuilder) FreeStyleProject(hudson.model.FreeStyleProject) MsgCheck(com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck)

Example 44 with StringParameterDefinition

use of hudson.model.StringParameterDefinition 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 45 with StringParameterDefinition

use of hudson.model.StringParameterDefinition in project wavefront-plugin-for-jenkins by vmware.

the class WavefrontBuildListenerTest method testSendingAllJobParametersToWavefront.

@Test
public void testSendingAllJobParametersToWavefront() throws Exception {
    List<String> expected = new ArrayList<>(Arrays.asList("p_branch=master", "p_isDevMode=true", "p_dummyParam=dummyValue"));
    WorkflowJob job = jenkinsRule.createProject(WorkflowJob.class, "Test Job");
    ParameterDefinition paramDef0 = new StringParameterDefinition("dummyParam", "dummyValue", "");
    ParameterDefinition paramDef1 = new StringParameterDefinition("branch", "master", "");
    ParameterDefinition paramDef2 = new BooleanParameterDefinition("isDevMode", true, "");
    ParametersDefinitionProperty prop = new ParametersDefinitionProperty(paramDef0, paramDef1, paramDef2);
    job.addProperty(prop);
    WavefrontJobProperty wavefrontJobProperty = mock(WavefrontJobProperty.class);
    when(wavefrontJobProperty.isEnableSendingJobParameters()).thenReturn(true);
    job.addProperty(wavefrontJobProperty);
    job.setDefinition(new CpsFlowDefinition("node {\n" + "}", true));
    jenkinsRule.buildAndAssertSuccess(job);
    List<String> messages = proxy.terminate();
    String actual = messages.get(0).replaceAll("[\"]", "");
    String message = "The expected point tags are not present";
    for (String e : expected) {
        if (!actual.contains(e)) {
            Assert.fail(message);
        }
    }
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) ArrayList(java.util.ArrayList) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) ParameterDefinition(hudson.model.ParameterDefinition) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) StringParameterDefinition(hudson.model.StringParameterDefinition) Test(org.junit.Test)

Aggregations

StringParameterDefinition (hudson.model.StringParameterDefinition)95 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)82 Test (org.junit.Test)77 FreeStyleProject (hudson.model.FreeStyleProject)69 ParametersAction (hudson.model.ParametersAction)45 StringParameterValue (hudson.model.StringParameterValue)44 FreeStyleBuild (hudson.model.FreeStyleBuild)43 Issue (org.jvnet.hudson.test.Issue)26 ParameterDefinition (hudson.model.ParameterDefinition)24 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)16 FileWriteBuilder (hudson.plugins.copyartifact.testutils.FileWriteBuilder)15 ArtifactArchiver (hudson.tasks.ArtifactArchiver)15 Shell (hudson.tasks.Shell)15 Cause (hudson.model.Cause)12 ArrayList (java.util.ArrayList)11 CIMessageNotifier (com.redhat.jenkins.plugins.ci.CIMessageNotifier)10 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)10 BooleanParameterDefinition (hudson.model.BooleanParameterDefinition)9 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)9 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)9