Reputation: 43
I am trying to run a bash script after a successful build in jenkins.
stages {
stage("test") {
steps {
...
}
post {
success {
steps {
sh "./myscript"
}
}
}
}
}
I am getting an error saying that method "steps" does not exist. How can I run a script after a successful build?
Upvotes: 0
Views: 2131
Reputation: 5742
You need to remove the ”steps” inside the ”success” block. call the script directly inside the ”success” block.
according to the docs which is quite confusing, the ”success” is a container for steps (so no need to add another nested ”steps” ):
stages {
stage("test") {
steps {
...
}
post {
success {
sh "./myscript"
}
}
}
}
Upvotes: 2