How can I do string to integer conversion in a Jenkinsfile?

前端 未结 2 564
心在旅途
心在旅途 2021-01-13 05:58

I have the following in my Jenkinsfile:

pipeline {
    agent none
    environment {
        timeout_mins = 1
    }
    options {
        timeout(time: "$         


        
2条回答
  •  独厮守ぢ
    2021-01-13 06:08

    As @burnettk says it’s a limitation with the options block. It's not the most elegant but you can use timeout as a step e.g.

    pipeline {
        agent none
        environment {
            timeout_mins = 1
        }
        stages {
            stage("test print") {
                steps {
                    timeout(time: env.timeout_mins.toInteger(), unit: 'MINUTES') {
                        echo "timeout_mins: ${env.timeout_mins}"
                        sh "sleep 120"
                    }
                }
            }
        }
    }
    

提交回复
热议问题