Jenkins管道作业:是否通过字符串参数设置睡眠时间? [英] Jenkins pipeline job: Set sleep time from a string parameter?

查看:98
本文介绍了Jenkins管道作业:是否通过字符串参数设置睡眠时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Jenkins Pipeline的新手,我面临着一个我无法解决的问题.

I'm new to Jenkins Pipeline jobs, and I'm facing an issue I cannot solve.

我有一个带有硬编码的sleep秒值的舞台:

I have a stage with a hardcoded sleep seconds value:

stage ("wait_prior_starting_smoke_testing") {
  echo 'Waiting 5 minutes for deployment to complete prior starting smoke testing'
  sleep 300 // seconds
}

但是我想通过作业(字符串)参数SLEEP_TIME_IN_SECONDS提供时间参数.但是无论我如何尝试,我都无法使其正常工作.

But I would like to provide the time argument via a job (string) parameter SLEEP_TIME_IN_SECONDS. But whatever I have tried, I am not able to get it to work.

如何将字符串参数转换为int时间参数?

How do you convert a string parameter to the int time argument?

推荐答案

最后,我确实找到了一种完成这项工作的方法:

Finally I did found a way to get this work:

stage ("wait_prior_starting_smoke_testing") {
    def time = params.SLEEP_TIME_IN_SECONDS
    echo "Waiting ${SLEEP_TIME_IN_SECONDS} seconds for deployment to complete prior starting smoke testing"
    sleep time.toInteger() // seconds
}

这篇关于Jenkins管道作业:是否通过字符串参数设置睡眠时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆