Sre*_*a E 4 jenkins jenkins-plugins jenkins-scriptler jenkins-cli
我想在不同的机器上使用相同的工作.但我不想每次都改变工作的配置.我可以将机器名称标签作为参数传递并在不同的机器上运行作业吗?(不是同时).
我想在运行作业时将参数传递给我在配置中编写的脚本(批处理脚本).我们可以这样做吗?
我可以从工作中获得返回值并在下一份工作中使用它吗?
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)
Run Code Online (Sandbox Code Playgroud)
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"
Run Code Online (Sandbox Code Playgroud)
6. Apply and save your Jenkins project.
7. Now your project is parameterized. Then your project should have Build with parameters option.
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
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");
Run Code Online (Sandbox Code Playgroud)
是的,您可以使用NodeLabel参数插件传递节点标签参数.
是的,您可以在参数化构建中定义参数,然后在脚本中将其用作环境变量:
该参数可用作环境参数.因此,例如shell($ FOO,%FOO%)或Ant($ {env.FOO})可以访问这些值.
| 归档时间: |
|
| 查看次数: |
12291 次 |
| 最近记录: |