Search in sources :

Example 91 with StringParameterDefinition

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

Example 92 with StringParameterDefinition

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

the class MavenBuildTest method testMavenWithDependencyVersionInEnvVar.

@Email("https://groups.google.com/d/msg/hudson-users/Xhw00UopVN0/FA9YqDAIsSYJ")
@Test
public void testMavenWithDependencyVersionInEnvVar() throws Exception {
    MavenModuleSet m = j.jenkins.createProject(MavenModuleSet.class, "p");
    MavenInstallation mavenInstallation = Maven36xBuildTest.configureMaven36();
    ParametersDefinitionProperty parametersDefinitionProperty = new ParametersDefinitionProperty(new StringParameterDefinition("JUNITVERSION", "3.8.2"));
    m.addProperty(parametersDefinitionProperty);
    m.setMaven(mavenInstallation.getName());
    m.getReporters().add(new TestReporter());
    m.setScm(new ExtractResourceSCM(getClass().getResource("envars-maven-project.zip")));
    m.setGoals("clean test-compile -Dmaven.compiler.target=1.8 -Dmaven.compiler.source=1.8");
    MavenModuleSetBuild mmsb = j.buildAndAssertSuccess(m);
    assertFalse(mmsb.getProject().getModules().isEmpty());
}
Also used : MavenInstallation(hudson.tasks.Maven.MavenInstallation) StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) ExtractResourceSCM(org.jvnet.hudson.test.ExtractResourceSCM) Email(org.jvnet.hudson.test.Email) Test(org.junit.Test)

Example 93 with StringParameterDefinition

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

the class WavefrontBuildListenerTest method testWhenWavefrontJobPropertyIsNull.

@Test
public void testWhenWavefrontJobPropertyIsNull() 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);
    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)

Example 94 with StringParameterDefinition

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

the class WavefrontBuildListenerTest method getJobParameters.

private List<ParameterDefinition> getJobParameters(int number) {
    List<ParameterDefinition> params = new ArrayList<>();
    int count = 0;
    while (count <= number) {
        StringParameterDefinition p = new StringParameterDefinition(String.valueOf(count + 1), "value_" + String.valueOf(count + 1), "");
        params.add(p);
        count++;
    }
    return params;
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) ArrayList(java.util.ArrayList) ParameterDefinition(hudson.model.ParameterDefinition) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) StringParameterDefinition(hudson.model.StringParameterDefinition)

Example 95 with StringParameterDefinition

use of hudson.model.StringParameterDefinition in project parallel-test-executor-plugin by jenkinsci.

the class ParallelTestExecutorTest method workflowDoesNotGenerateInclusionsFromRunningBuild.

@Test
@Issue("JENKINS-53172")
public void workflowDoesNotGenerateInclusionsFromRunningBuild() throws Exception {
    WorkflowJob p = jenkinsRule.jenkins.createProject(WorkflowJob.class, "p");
    ParameterDefinition sleepDef = new StringParameterDefinition("SLEEP", "100", "");
    ParametersDefinitionProperty sleepParamsDef = new ParametersDefinitionProperty(sleepDef);
    p.addProperty(sleepParamsDef);
    /* We need to wait for first build to generate test result before calling splitTests in the second build, So
        * instead of trying to use a quiet period, which is not deterministic and will introduce potential flakiness,
        * we use the existing locking and milestone facilities in pipeline to make sure that
        *  a) The second run waits until the first one has generated tests results by using a lock
        *  b) Once the second build finish the previous one is killed by using milestones
        */
    p.setDefinition(new CpsFlowDefinition("lock('test-results') {\n" + "  def splits = splitTests parallelism: count(2), generateInclusions: true\n" + "  echo \"splits.size=${splits.size()}\"; for (int i = 0; i < splits.size(); i++) {\n" + "    def split = splits[i]; echo \"splits[${i}]: includes=${split.includes} list=${split.list}\"\n" + "  }\n" + "  node {\n" + "    writeFile file: 'TEST-1.xml', text: '<testsuite name=\"one\"><testcase name=\"x\" failures=\"1\"/></testsuite>'\n" + "    writeFile file: 'TEST-2.xml', text: '<testsuite name=\"two\"><testcase name=\"y\"/></testsuite>'\n" + "    junit 'TEST-*.xml'\n" + // Needed due to https://issues.jenkins-ci.org/browse/JENKINS-48178
    "    currentBuild.result = 'UNSTABLE'\n" + "  }\n" + "}\n" + "milestone 1\n" + "sleep time: Integer.valueOf(params.SLEEP), unit: 'SECONDS'\n" + "milestone 2", true));
    WorkflowRun b1 = p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("SLEEP", "100"))).waitForStart();
    jenkinsRule.waitForMessage("Lock acquired on", b1);
    WorkflowRun b2 = p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("SLEEP", "0"))).get();
    jenkinsRule.assertLogContains("splits.size=1", b2);
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) StringParameterValue(hudson.model.StringParameterValue) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) ParametersAction(hudson.model.ParametersAction) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) StringParameterDefinition(hudson.model.StringParameterDefinition) ParameterDefinition(hudson.model.ParameterDefinition) Issue(org.jvnet.hudson.test.Issue) 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