I have the following in my Jenkinsfile:
pipeline {
agent none
environment {
timeout_mins = 1
}
options {
timeout(time: "$
it's not the conversion that's failing, it's just that you can't reference environment variables in the options block.
this also fails (nullpointer exception):
pipeline {
agent none
environment {
timeout_mins = 'MINUTES'
}
options {
timeout(time: 1, unit: env.timeout_mins)
}
stages {
stage("test print") {
steps {
echo "timeout_mins: ${env.timeout_mins}"
sh "sleep 120"
}
}
}
}
this works:
def timeout_in_minutes = 1
pipeline {
agent none
options {
timeout(time: timeout_in_minutes, unit: 'MINUTES')
}
stages {
stage("test print") {
steps {
echo "timeout_in_minutes: ${env.timeout_in_minutes}"
sh "sleep 120"
}
}
}
}