有的时候不同job直接需要传递一个文件名或者路径,这个时候我们不需要传递文件实体,那这个路径如何传递呢?比如有如下两个项目,我想把A的工作目录传递给B,让B使用。

A job配置

首先需要安装一个Parameterized Trigger Plugin插件:

安装后重启。

在A项目配置面板中Post-build Actions选项中选择Trigger parameterized build on other projects
我选择的参数为预定义参数,如果想知道有哪些与定义参数,可以在Build模块下选择Execute shell

选在文本框下的the list of available environment variables 选项,可以查看如下信息:

The following variables are available to shell scripts

BUILD_NUMBER
The current build number, such as "153"
BUILD_ID
The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
BUILD_DISPLAY_NAME
The display name of the current build, which is something like "#153" by default.
JOB_NAME
Name of the project of this build, such as "foo" or "foo/bar". (To strip off folder paths from a Bourne shell script, try: ${JOB_NAME##*/})
BUILD_TAG
String of "jenkins-${JOB_NAME}-${BUILD_NUMBER}". Convenient to put into a resource file, a jar file, etc for easier identification.
EXECUTOR_NUMBER
The unique number that identifies the current executor (among executors of the same machine) that’s carrying out this build. This is the number you see in the "build executor status", except that the number starts from 0, not 1.
NODE_NAME
Name of the slave if the build is on a slave, or "master" if run on master
NODE_LABELS
Whitespace-separated list of labels that the node is assigned.
WORKSPACE
The absolute path of the directory assigned to the build as a workspace.
JENKINS_HOME
The absolute path of the directory assigned on the master node for Jenkins to store data.
JENKINS_URL
Full URL of Jenkins, like http://server:port/jenkins/ (note: only available if Jenkins URL set in system configuration)
BUILD_URL
Full URL of this build, like http://server:port/jenkins/job/foo/15/ (Jenkins URL must be set)
JOB_URL
Full URL of this job, like http://server:port/jenkins/job/foo/ (Jenkins URL must be set)
SVN_REVISION
Subversion revision number that's currently checked out to the workspace, such as "12345"
SVN_URL
Subversion URL that's currently checked out to the workspace.

ok,回到正题,具体配置如下:

我将A项目的工作目录传递给了自定义参数TEST_WORKSPACE.到这里A项目的配置就完成了。

B job配置

我们在A项目配置的TEST_WORKSPACE参数,如果在B job中使用,首先我们在配置界面中,勾选The build is parameterized。具体配置信息如下所示:

这样我们就在当前工作环境中得到了由A传递过来的参数。至于你怎么使用,那是你的事了。比如我在shell脚本中首先切换到该目录下(需要在一台机器上),然后在A项目的工作目录下生成一个hello.txt文档,我们可以在shell命令下配置如下信息:

ok,配置完成了,这个时候我们构建A,看看能不能让B在A的工作目录下生成一个hello.txt文档。

Done!

最新文章

  1. 【无私分享:ASP.NET CORE 项目实战(第三章)】EntityFramework下领域驱动设计的应用
  2. Python-类的属性
  3. mysql中获取一天、一周、一月时间数据的各种sql语句写法
  4. 【整理】-- C++ 多线程
  5. Shader的语法
  6. 一些在IOS中关于JS、H5开发的网站
  7. FileInputStream利用缓冲数组读取数据
  8. phpcms常用接口调用方法
  9. 各种排序算法及c语言实现
  10. Android - 软件自动更新的实现(转)
  11. Python自动化中的元素定位(一)
  12. Quartus prime16.0 与modelsim ae 联调
  13. HDU2853 Assignment KM
  14. P4512 【模板】多项式除法
  15. vxlan中vtep角色,以及通过GRE隧道进行流镜像
  16. Yii数据对象笔记
  17. 四则运算3+PSP
  18. 《在kali上完成gdb调试》
  19. sql server 定期自动清理日志
  20. Jmeter之集合点与关联

热门文章

  1. 图书管理系统(无中间件,用装饰器的)-----未基于FORM组件
  2. 【linux】shell代码,获取当前路径,创建文件夹
  3. LeetCode(2): 两数相加
  4. collections模块
  5. vue用webpack打包时引入es2015插件
  6. 优先选择nullptr而不是0和NULL
  7. 用servlet打内容到网页上
  8. Redis设置内存最大占用值
  9. Dom,查找标签和操作标签
  10. CentOS6—HAProxy安装与配置