Jenkins在MultiJob项目中使用文件参数 [英] Jenkins using File Parameter with MultiJob Project
问题描述
我正在使用MultiJob项目,以便在每次推送到某个Git分支时实现一个运行过程.
I am using the MultiJob Project in order to implement a process the runs every time there is a push to a certain Git branch.
如何在2个不同的作业之间传递参数(每个作业位于单独的MultiJob阶段)
How can I pass parameters between 2 different jobs (each job is located in a separate MultiJob Phase)
我想做的是:
工作A :(在主计算机上运行-Windows)
Job A: (Run on the Master - windows)
将2个参数回显到我放置在共享位置(而不是作业A的工作空间中)的新文件(称为parameters.properties)中
echo 2 parameters into a new file (Called parameters.properties) that i placed in a shared location (not in the workspace of Job A)
因此该文件的内容类似于:
so this file's contnet looks like:
currentBuild=2012-11-27_09-20-50
currentBranch=master
作业B :(在Linux从站上运行)
Job B: (Run on a Linux Slave)
此构建已参数化"选项处于启用状态.
The option of "This build is parametrized" is on.
添加了文件参数",仅添加了文件名,因为我还将自定义工作区设置为文件所在的共享位置.
Added "File Parameter" and only the file name as I also set a custom workspace to the shared location where the file is located.
我有一个尝试使用此参数的shell脚本,但没有得到它.
The i have a shell script that tries to use this parametrs but it doesnt get it.
请协助
Doron
推荐答案
解决方案:
-
在MultiJob主项目中:
in the MultiJob Main Project:
-
设置此构建已参数化"
Set "This build is parametrized"
添加2个文本参数(由于Job Build基于Jenkins变量Build_Id,因此具有不同的名称,并且已更改,我希望稍后将currentBuild设置为恒定值而不是新值)
Add 2 Text Parameters (different names since the Job Build is based on Jenkins variable Build_Id which is changed and i want later to set the currentBuild to a constant value and not to a new one)
-
JobBuild
JobBuild
工作分支
在每个MultiJob阶段下的每个作业上:
On each Job under each MultiJob Phase:
-
添加预定义参数:
Add Predefined Parameters:
-
currentBuild = $ {JobBuild}
currentBuild=${JobBuild}
currentBranch = $ {JobBranch}
currentBranch=${JobBranch}
取消选中当前作业参数"
untick the "Current job parameters"
取消选中暴露的SCM"
untick the Exposed SCM"
这篇关于Jenkins在MultiJob项目中使用文件参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!