Jenkins 詹金斯管道-该;超时“;指令不可配置环境变量

Jenkins 詹金斯管道-该;超时“;指令不可配置环境变量,jenkins,jenkins-pipeline,timeout,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: 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吗?我想知道是否有人找到了使用变量指定超时的方法