Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-70680] Reproducing issue with properties + parameters + defaultValue #235

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import jenkins.plugins.git.GitSCMSource;
import jenkins.plugins.git.GitBranchSCMHead;
import jenkins.plugins.git.GitSampleRepoRule;
import jenkins.plugins.git.traits.BranchDiscoveryTrait;
import jenkins.triggers.ReverseBuildTrigger;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMSource;
Expand All @@ -79,6 +80,7 @@
import org.junit.After;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.BuildWatcher;
Expand Down Expand Up @@ -231,6 +233,32 @@ public void testPreviousBuildFailedHard() throws Exception {
r.assertLogContains("value bar", b9);
}

@Ignore("TODO does not currently work; b2 says subsequently received #1")
@Issue("JENKINS-70680")
@Test public void changingParameterDefault() throws Exception {
sampleRepo.init();
sampleRepo.write("Jenkinsfile", "properties([parameters([string(name: 'x', defaultValue: '#1')])]); echo(/initially received $params.x/)");
sampleRepo.git("add", "Jenkinsfile");
sampleRepo.git("commit", "--message=1");
WorkflowMultiBranchProject mp = r.createProject(WorkflowMultiBranchProject.class, "mp");
GitSCMSource source = new GitSCMSource(sampleRepo.toString());
source.setTraits(List.of(new BranchDiscoveryTrait()));
mp.getSourcesList().add(new BranchSource(source));
WorkflowJob p = scheduleAndFindBranchProject(mp, "master");
assertEquals(1, mp.getItems().size());
r.waitUntilNoActivity();
WorkflowRun b1 = p.getLastBuild();
assertEquals(1, b1.getNumber());
r.assertLogContains("initially received #1", b1);
sampleRepo.write("Jenkinsfile", "properties([parameters([string(name: 'x', defaultValue: '#2')])]); echo(/subsequently received $params.x/)");
sampleRepo.git("commit", "--all", "--message=2");
scheduleAndFindBranchProject(mp, "master");
r.waitUntilNoActivity();
WorkflowRun b2 = p.getLastBuild();
assertEquals(2, b2.getNumber());
r.assertLogContains("subsequently received #2", b2);
}

@Issue({"JENKINS-27295", "https://www.jenkins.io/security/advisory/2016-05-11/#arbitrary-build-parameters-are-passed-to-build-scripts-as-environment-variables"})
@Test public void triggerWithParameter() throws Exception {
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
Expand Down