如何创建参数化Jenkins作业?

如何创建参数化Jenkins作业?,jenkins,jenkins-plugins,jenkins-cli,jenkins-scriptler,Jenkins,Jenkins Plugins,Jenkins Cli,Jenkins Scriptler,我想在不同的机器上使用相同的作业。但我不想每次都更改作业的配置。我是否可以将机器名称标签作为参数传递,并在不同的机器上运行作业?不是同时 我想在运行作业时将参数传递给我在配置批处理脚本中编写的脚本。我们能做到吗 我可以从作业中获取返回值并在下一个作业中使用它吗?使用和 是的,可以使用传递节点标签参数 是的,您可以在中定义参数(如所述),然后在脚本中将其用作环境变量: 该参数可用作环境参数。因此,例如shell$FOO、%FOO%或Ant${env.FOO}可以访问这些值 这并不完全是一个返回值,

我想在不同的机器上使用相同的作业。但我不想每次都更改作业的配置。我是否可以将机器名称标签作为参数传递,并在不同的机器上运行作业?不是同时

我想在运行作业时将参数传递给我在配置批处理脚本中编写的脚本。我们能做到吗

我可以从作业中获取返回值并在下一个作业中使用它吗?

使用和

是的,可以使用传递节点标签参数

是的,您可以在中定义参数(如所述),然后在脚本中将其用作环境变量:

该参数可用作环境参数。因此,例如shell$FOO、%FOO%或Ant${env.FOO}可以访问这些值

这并不完全是一个返回值,但您可以使用将任何参数及其值传递给下游作业。


我不能使用windows批处理脚本并传递参数吗?它讨论了shell脚本和Ant,请帮助我将windows批处理脚本中的参数指示给我们。我知道了!!在脚本中使用%param%!!:
Example criteria:
User needs to use different environments for executions.

1. Select jenkins project
2. Job -> Configure -> Select this project is parameterized check box.
3. Select Add parameter drop down - > String parameter
4. Define a string parameter (In my example I use environment variable as : BaseURL)
5.Now under build section initialize the mvn command user needs to execute.Here in this case I want to execute my jenkins build on a environment where I specify. So I should be able to execute my build in different environment each time with out changing the code.

My mvn command: I pass my environment url as a parameter (Using $ sign). This is based on user requirement. 
clean test -Dcustomproperty="$BaseURL"
6. Apply and save your Jenkins project.
7. Now your project is parameterized.  Then your project should have Build with parameters option.
8.Click Build with parameters link and enter your parameter (In this example my environment variable) and click build. Your jenkins job should run with the parameter.
NOTE: This build won't succeed unless the passing parameter is not utilized in the automation script. So script has to be modified to retrieve the passing variable.

String BaseURL= System.getProperty("customproperty");