Jenkins管道-无法使用环境变量配置“超时”指令

时间:2020-09-21 16:12:44

标签: jenkins jenkins-pipeline timeout

我试图弄清楚,为什么在超时中使用变量不起作用?在下面的示例中-一切正常。

pipeline {
    agent any
    options {
        timeout(time: 1, unit: 'HOURS') 
    }
    stages {
        stage('Example') {
            steps {
                echo 'Hello World'
            }
        }
    }
}

但是当我尝试用环境变量控制超时时,它不起作用:

pipeline {
    agent any
    options {
        timeout(time: env.MANAGED_TIMEOUT.toInteger(), unit: 'HOURS')
        // same story without toInteger :(
    }
    stages {
        stage('Example') {
            steps {
                echo 'Hello World'
            }
        }
    }
}

这也是由于CPS吗?我想知道是否有人找到一种使用变量指定超时的方法。

0 个答案:

没有答案