Created
May 16, 2017 22:46
-
-
Save bhenderson/fc44192a980df3b2a2852a65d0dd5621 to your computer and use it in GitHub Desktop.
Jenkinsfile with validation dsl (does not work!)
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
validator { | |
validate 'hello' | |
validate 'world' | |
} |
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
[Pipeline] node | |
Running on master in /var/jenkins_home/workspace/validator | |
[Pipeline] { | |
[Pipeline] stage | |
[Pipeline] { (Validate) | |
[Pipeline] echo | |
hello | |
[Pipeline] echo | |
world | |
[Pipeline] } | |
[Pipeline] } | |
[Pipeline] End of Pipeline | |
Finished: FAILURE |
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
// src/conveyor/Validator.groovy | |
package conveyor | |
class Validator { | |
def messages = [] | |
def validate(String msg) { | |
messages.add(msg) | |
} | |
} |
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
// vars/validator.groovy | |
import conveyor.Validator | |
def call(Closure body) { | |
def validator = new Validator() | |
body.resolveStrategy = Closure.DELEGATE_FIRST | |
body.delegate = validator | |
body() | |
node('master') { | |
stage('Validate') { | |
for(def m : validator.messages) { | |
echo(m) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why does the pipeline fail?