Im readind a shell script file /tmp/cmd_list.sh with groove script and creating a dynamic stage to build.
The content of /tmp/cmd_list.sh is:
ls pwd aaaaaa who
Only "aaaaaa" mut fail to execute (exit code 127). My problem is, all stages are marked as failed, but when i see the log, comands such as "ls", "pwd" and "who" work fine fine and return code is 0.
I tried to foce stage status for box, but without sucess ... My Groove script (Jenkinsfile):
import hudson.model.Result
node('master') {
stage ('\u27A1 Checkout'){
sh "echo 'checkout ok'"
}
def BUILD_LIST = readFile('/tmp/cmd_list.sh').split()
for (CMDRUN in BUILD_LIST) {
def status;
try {
node{
stage(CMDRUN) {
println "Building ..."
status = sh(returnStatus: true, script: CMDRUN )
println "---> EX CODE: "+ status
if(status == 0){
currentBuild.result = 'SUCCESS'
currentBuild.rawBuild.@result = hudson.model.Result.SUCCESS
}
else{
currentBuild.result = 'UNSTABLE'
currentBuild.rawBuild.@result = hudson.model.Result.UNSTABLE
}
def e2e = build job:CMDRUN, propagate: false
}
}
}
catch (e) {
println "===> " + e
currentBuild.result = 'UNSTABLE'
println "++++> EX CODE: "+ status
if(status == 0){
println "++++> NEW STATUS: "+ status
currentBuild.rawBuild.@result = hudson.model.Result.SUCCESS
currentBuild.result = 'SUCCESS'
}
else{
println "++++> NEW STATUS: "+ status
currentBuild.rawBuild.@result = hudson.model.Result.UNSTABLE
}
}
}
}
And the result is:
Anyone can help me to show right status? Thank you!