有的时候不同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!

Jenkins不同job之间传递参数的更多相关文章

  1. mvc中view与controll之间传递参数时,可以使用url进行传递

    mvc中view与controller之间传递参数时,可以使用url进行传递,但是在url的地址中需要加上“id=123”这样的东西才行. 具体如代码: window.location.href = ...

  2. JSP页面之间传递参数的方法有哪些?

    JSP页面之间传递参数的方法有哪些? 解答: 1)request 2)session 3)application 4)提交表单 5)超链接

  3. ASP.NET网页之间传递参数与值

    ASP.NET网页之间传递参数与值,方法很多,可以使用Application,Cookie,Session,或是Querystring等等.由于Insus.NET开发的程序中,多数是在后台之间进行参数 ...

  4. JS多个函数之间传递参数问题

    JS多个函数之间传递参数的一个重要思想是在页面定义一个隐藏域,当第一个函数请求到数据时候修改隐藏域的值,第二个函数用jQuery的选择器选择页面中隐藏域的值. 比如: 页面中定义一个隐藏的页号. &l ...

  5. Android学习总结——Activity之间传递参数

    核心内容:一.在 Activity 之间传递简单数据二.在 Activity 之间传递复杂数据 三.在 Activity 之间传递自定义值对象   软件环境:Android Studio   一.在 ...

  6. Android——软键盘操作+fragment之间传递参数+TextView限制字数,显示"..."

    原文地址: Android 手动显示和隐藏软键盘 Android隐藏输入法键盘(hideSoftInputFromInputMethod没有效果) Android Fragment传递参数_Fragm ...

  7. bean shell之间传递参数

    BeanShell PostProcessor 向 BeanShell断言 传递参数 断言成功:

  8. SpringMvc中两个Controller类之间传递参数的方法

    使用SpringMvc框架,在访问ControllerA的时候,将A里面的参数传递到ControllerB中.适用于同一框架下两个不同Controller或者由rpc(dubbo)连接的两个工程里的C ...

  9. angular中控制器之间传递参数的方式

    在angular中,每个controller(控制器)都会有自己的$scope,通过为这个对象添加属性赋值,就可以将数据传递给模板进行渲染,每个$scope只会在自己控制器内起作用,而有时候需要用到其 ...

随机推荐

  1. Max Sum (dp)

    Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. F ...

  2. anaconda中的包如何传到pycharm中使用?

    在pycharm的setting中设置 在project interpreter 中的 existing environment 中选择 anaconda3安装目录下的的 python.exe 就可以 ...

  3. MyBatis - 6.Spring整合MyBatis

    1.查看不同MyBatis版本整合Spring时使用的适配包: http://www.mybatis.org/spring/ 2.下载整合适配包 https://github.com/mybatis/ ...

  4. Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#<Object>‘的解决方法

    发现问题 运行一下以前的一个Vue+webpack的 vue仿新闻网站  小项目,报错 由于自己vue学习不深入,老是这个报错,找了好久(确切的说是整整一下午^...^)才找到原因 -v- Uncau ...

  5. Processing3 1.随机行走

    class Walker { int x; int y; Walker() { x = width/2; y = height/2; } void display() { stroke(0); poi ...

  6. 计算1至n中数字X出现的次数【math】

    转自: nailperry 一.1的数目 编程之美上给出的规律: 1. 如果第i位(自右至左,从1开始标号)上的数字为0,则第i位可能出现1的次数由更高位决定(若没有高位,视高位为0),等于更高位数字 ...

  7. cookie 详解

    cookie概览 cookie是Web浏览器存储的少量命名数据,它与某个特定的网页或网站关联在一起.cookie是用来给Web浏览器提供内存,以便脚本和服务端程序可以在一个页面使用另一个页面的输入数据 ...

  8. get、post的区别

    Get.post请求的区别 前言 不论是get还是post方式,都是属于http协议,只是http的两种不同的传输方式,而http协议是基于TCP传输协议的,所以无论是get还是post,在传输层的意 ...

  9. 获取Form表单数据转化成JSON对象

    $.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() ...

  10. BZOJ2209 [Jsoi2011]括号序列 splay

    原文链接http://www.cnblogs.com/zhouzhendong/p/8093556.html 题目传送门 - BZOJ2209 题解 我太弱了,调出这题感觉都要吐了. 题解懒得写了. ...