Skip to content

Commit

Permalink
Merge pull request #104 from abayer/jenkins-41490-jenkins-41491
Browse files Browse the repository at this point in the history
[FIXED JENKINS-41490, JENKINS-41491] Tree steps and validation!
  • Loading branch information
abayer committed Jan 27, 2017
2 parents 3a0ee95 + e4aae36 commit ca9c202
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 5 deletions.
9 changes: 8 additions & 1 deletion pipeline-model-api/src/main/resources/ast-schema.json
Expand Up @@ -228,7 +228,14 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"items": { "items": {
"$ref": "#/definitions/step" "anyOf": [
{
"$ref": "#/definitions/step"
},
{
"$ref": "#/definitions/treeStep"
}
]
} }
} }
}, },
Expand Down
Expand Up @@ -260,9 +260,6 @@ class ModelValidatorImpl implements ModelValidator {
valid = false valid = false
} else { } else {
Class erasedType = p?.erasedType Class erasedType = p?.erasedType
if (lookup.stepTakesClosure(desc)) {
erasedType = String.class
}
def v = arg.value; def v = arg.value;


if (!validateParameterType(v, erasedType)) { if (!validateParameterType(v, erasedType)) {
Expand Down
Expand Up @@ -138,7 +138,8 @@ public void setUp() throws Exception {
"whenBranchFalse", "whenBranchFalse",
"whenEnvFalse", "whenEnvFalse",
"parallelPipelineWithSpaceInBranch", "parallelPipelineWithSpaceInBranch",
"parallelPipelineQuoteEscaping" "parallelPipelineQuoteEscaping",
"nestedTreeSteps"
); );


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


@Test
public void nestedTreeSteps() throws Exception {
expect("nestedTreeSteps")
.logContains("[Pipeline] { (foo)", "[Pipeline] timeout", "[Pipeline] retry", "hello")
.go();
}

@Test @Test
public void metaStepSyntax() throws Exception { public void metaStepSyntax() throws Exception {
env(s).set(); env(s).set();
Expand Down
@@ -0,0 +1,45 @@
{"pipeline": {
"stages": [ {
"name": "foo",
"branches": [ {
"name": "default",
"steps": [ {
"name": "timeout",
"arguments": [
{
"key": "time",
"value": {
"isLiteral": true,
"value": 5
}
},
{
"key": "unit",
"value": {
"isLiteral": true,
"value": "SECONDS"
}
}
],
"children": [ {
"name": "retry",
"arguments": {
"isLiteral": true,
"value": 4
},
"children": [ {
"name": "echo",
"arguments": [ {
"key": "message",
"value": {
"isLiteral": true,
"value": "hello"
}
}]
}]
}]
}]
}]
}],
"agent": {"type": "none"}
}}
@@ -0,0 +1,41 @@
/*
* The MIT License
*
* Copyright (c) 2017, 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 {
timeout(time: 5, unit: "SECONDS") {
retry(4) {
echo "hello"
}
}
}
}
}
}



0 comments on commit ca9c202

Please sign in to comment.