Skip to content

Commit

Permalink
[FIXED JENKINS-40580] Quote parallel branch names
Browse files Browse the repository at this point in the history
Decided to be defensive and always quote when converting, rather than
trying to figure out when we could avoid quoting.
  • Loading branch information
abayer committed Dec 20, 2016
1 parent a1963cd commit 1f595c9
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 2 deletions.
Expand Up @@ -112,7 +112,7 @@ public String toGroovy() {
result.append(',');
}
result.append('\n');
result.append(branch.getName()).append(": {\n").append(branch.toGroovy()).append("\n}");
result.append('"' + branch.getName() + '"').append(": {\n").append(branch.toGroovy()).append("\n}");
}
if (failFast != null && failFast) {
result.append(",\nfailFast: true");
Expand Down
Expand Up @@ -131,7 +131,8 @@ public void setUp() throws Exception {
"environmentInStage",
"basicWhen",
"skippedWhen",
"parallelPipelineWithFailFast"
"parallelPipelineWithFailFast",
"parallelPipelineWithSpaceInBranch"
);

public static Iterable<Object[]> configsWithErrors() {
Expand Down
Expand Up @@ -160,6 +160,13 @@ public void parallelPipeline() throws Exception {
.go();
}

@Test
public void parallelPipelineWithSpaceInBranch() throws Exception {
expect("parallelPipelineWithSpaceInBranch")
.logContains("[Pipeline] { (foo)", "[first one] { (Branch: first one)", "[second one] { (Branch: second one)")
.go();
}

@Test
public void parallelPipelineWithFailFast() throws Exception {
expect("parallelPipelineWithFailFast")
Expand Down
@@ -0,0 +1,31 @@
{"pipeline": {
"stages": [ {
"name": "foo",
"branches": [
{
"name": "first one",
"steps": [ {
"name": "echo",
"arguments": {
"isLiteral": true,
"value": "First branch"
}
}]
},
{
"name": "second one",
"steps": [ {
"name": "echo",
"arguments": {
"isLiteral": true,
"value": "Second branch"
}
}]
}
]
}],
"agent": {
"isLiteral": true,
"value": "none"
}
}}
@@ -0,0 +1,42 @@
/*
* The MIT License
*
* Copyright (c) 2016, CloudBees, Inc.
*
* 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.
*/

pipeline {
agent none
stages {
stage("foo") {
steps {
parallel("first one": {
echo "First branch"
},
"second one": {
echo "Second branch"
})
}
}
}
}



0 comments on commit 1f595c9

Please sign in to comment.