Issue
I have a jenkins pipeline where I have 2 stages:
pipelien {
agent {label 'master'}
stages ('stage 1') {
stage {
steps {
sh "python3 script.py" //this script returns value {"status": "ok"}
}
}
stage ('stage 2') {
// Do something with the response JSON from script.py
}
}
}
The issue is that I cannot do it. What I have tries:
- Pass the result to an environment variable, but for some reason Jenkins didn't recognize it. Maybe I did something wrong here?
- Playing an parsing stdout of script.py is not an option, because this script prints lot of logs
The only option which is left is to create a file to store that JSON and then to read that file in the next step, but it's ugly.
Any ideas?
Solution
In the end we chose to create files and store the messages there. We pass the file name as an argument to python script and log everything. We then remove all the workspace after the job succeeds.
Answered By - Aladin