如何创建参数化的詹金斯职位? [英] How can I create parameterized Jenkins job?
问题描述
我想在不同的机器上使用相同的作业.但是我不想每次都更改作业的配置.我可以将机器名称标签作为参数传递并在另一台机器上运行作业吗? (不是同时).
I want to use same job in different machine. But I don't want to change the configuration of the job each time. Can I pass the machine name label as parameter and run the job in different machine ? (Not simultaneously).
我想在将作业运行到我在配置中编写的脚本(批处理脚本)时传递参数.我们可以做到吗?
I want to pass parameters while running a job to the script which I have written in th configuration (batch script). Can we do that ?
我可以从一个工作中获得返回值,并在下一个工作中使用它吗?
Can I get a return value from a job and use it in next job?
推荐答案
-
是的,您可以使用传递节点标签参数NodeLabel参数插件.
是的,您可以按照参数化中的描述定义参数构建,然后在脚本中将其用作环境变量:
Yes, you can define parameters, as described, in Parameterized Builds and then use it in your script as an environment variable:
该参数可用作环境参数.所以外壳程序($ FOO,%FOO%)或Ant($ {env.FOO})可以访问这些值.
The parameter is available as environment parameters. So e.g. a shell ($FOO, %FOO%) or Ant ( ${env.FOO} ) can access these values.
- 这不完全是一个返回值,但是您可以使用 查看全文