This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into JENKINS-26122
* master: [JENKINS-27145] Noting #75 in changelog. Updating list of unavailable variables (again :) ). [FIXED JENKINS-26692] Added BuildTriggerStep.quietPeriod. @tfennelly requests more descriptive variable names. Needed to update a test as well. [FIXED JENKINS-26072] Added WorkspaceStep.dir. Updating list of unavailable variables. Linking to environment variable (${rootURL}/env-vars.html) in the workflow script help page. Conflicts: CHANGES.md
- Loading branch information
Showing
13 changed files
with
249 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/WorkspaceStepTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2015 Jesse Glick. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package org.jenkinsci.plugins.workflow.steps; | ||
|
||
import hudson.slaves.DumbSlave; | ||
import java.io.File; | ||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowRun; | ||
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep; | ||
import org.junit.Test; | ||
import org.junit.Rule; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
public class WorkspaceStepTest { | ||
|
||
@Rule public JenkinsRule r = new JenkinsRule(); | ||
|
||
@Issue("JENKINS-26072") | ||
@Test public void customWorkspace() throws Exception { | ||
DumbSlave s = r.createSlave(); | ||
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); | ||
p.setDefinition(new CpsFlowDefinition("node('" + s.getNodeName() + "') {ws('custom-location') {echo pwd()}}", true)); | ||
r.assertLogContains(s.getRemoteFS() + File.separator + "custom-location", r.assertBuildStatusSuccess(p.scheduleBuild2(0))); | ||
} | ||
|
||
@Issue("JENKINS-26072") | ||
@Test public void customWorkspaceConcurrency() throws Exception { | ||
// Currently limited to WorkspaceList.allocate: | ||
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); | ||
// Use master as it has 2 executors by default, whereas createSlave hardcodes 1, and I do not want to bother creating a slave by hand: | ||
p.setDefinition(new CpsFlowDefinition("node {ws('custom-location') {echo pwd(); semaphore 'customWorkspace'}}", true)); | ||
WorkflowRun b2 = p.scheduleBuild2(0).getStartCondition().get(); | ||
SemaphoreStep.waitForStart("customWorkspace/1", b2); | ||
WorkflowRun b3 = p.scheduleBuild2(0).getStartCondition().get(); | ||
SemaphoreStep.waitForStart("customWorkspace/2", b3); | ||
SemaphoreStep.success("customWorkspace/1", null); | ||
SemaphoreStep.success("customWorkspace/2", null); | ||
while (b2.isBuilding() || b3.isBuilding()) { | ||
Thread.sleep(100); | ||
} | ||
r.assertBuildStatusSuccess(b2); | ||
r.assertBuildStatusSuccess(b3); | ||
String location = new File(r.jenkins.getRootDir(), "custom-location").getAbsolutePath(); | ||
r.assertLogContains(location, b2); | ||
r.assertLogNotContains("custom-location@", b2); | ||
r.assertLogContains(location + "@2", b3); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...c/main/resources/org/jenkinsci/plugins/workflow/support/steps/WorkspaceStep/help-dir.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<p> | ||
A workspace is automatically allocated for you with the <code>node</code> step, | ||
or you can get an alternate workspace with this <code>ws</code> step, | ||
but by default the location is chosen automatically. | ||
(Something like <code>SLAVE_ROOT/workspace/JOB_NAME@2</code>.) | ||
</p> | ||
<p> | ||
You can instead specify a path here and that workspace will be locked instead. | ||
(The path may be relative to the slave root, or absolute.) | ||
</p> | ||
<p> | ||
If concurrent builds ask for the same workspace, a directory with a suffix such as <code>@2</code> may be locked instead. | ||
Currently there is no option to wait to lock the exact directory requested; | ||
if you need to enforce that behavior, you can either fail (<code>error</code>) when <code>pwd</code> indicates that you got a different directory, | ||
or you may enforce serial execution of this part of the build by some other means such as <code>stage name: '…', concurrency: 1</code>. | ||
</p> | ||
<p> | ||
If you do not care about locking, just use the <code>dir</code> step to change current directory. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStep/help-quietPeriod.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div> | ||
Optional alternate quiet period (in seconds) before building. | ||
If unset, defaults to the quiet period defined by the downstream project | ||
(or finally to the system-wide default quiet period). | ||
</div> |
51 changes: 51 additions & 0 deletions
51
...rc/test/java/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStepTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2015 Jesse Glick. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package org.jenkinsci.plugins.workflow.support.steps.build; | ||
|
||
import org.jenkinsci.plugins.workflow.steps.StepConfigTester; | ||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
import org.junit.Rule; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
public class BuildTriggerStepTest { | ||
|
||
@Rule public JenkinsRule r = new JenkinsRule(); | ||
|
||
@Issue("JENKINS-26692") | ||
@Test public void configRoundTrip() throws Exception { | ||
BuildTriggerStep s = new BuildTriggerStep("ds"); | ||
s = new StepConfigTester(r).configRoundTrip(s); | ||
assertEquals(null, s.getQuietPeriod()); | ||
s.setQuietPeriod(5); | ||
s = new StepConfigTester(r).configRoundTrip(s); | ||
assertEquals(Integer.valueOf(5), s.getQuietPeriod()); | ||
s.setQuietPeriod(0); | ||
s = new StepConfigTester(r).configRoundTrip(s); | ||
assertEquals(Integer.valueOf(0), s.getQuietPeriod()); | ||
} | ||
|
||
} |