前言:

本文介绍插件: Parameterized Trigger plugin的具体使用方法。


一、插件介绍

Parameterized Trigger plugin插件可以让你在构建完成时触发新的Job构建,并以各种方式为新Job构建指定参数。
当然也可以添加多个配置:每个配置都有一个要触发的Job,触发时间的条件(基于当前构建的结果)和参数部分。


二、使用方法

1、项目Test_A,配置-构建后操作-配置如下信息:

选择【Trigger parameterized build on other projects】

【Projects to build】:项目名称
【Trigger when build is】:项目执行状态
【Add Parameters】:添加需要传的参数

1、【Predefined parameters】:预定义参数,后续的job的入参与当前job的参数名称不一致,或者有新参数的时候,可以使用该传参方式。
局限:后续job的入参的值要么固定,要么由环境变量和入参进行简单的组合获取,无法融入逻辑语句。
2、【Current build parameters】:后续job的入参和用到当前job的入参的时候,可是使用该传参方式。
局限:参数取决于当前的job
3、【Parameters from properties file】:若后续job的入参的值需要一定逻辑处理才能获取,那么,这种传参方式就特别好用了,比较灵活。
本次传参例子为:JOB_NAME=${JOB_NAME}

2、项目Test_B,配置-参数化构建过程-配置如下信息:

选择【参数化构建过程】

【添加参数-字符参数】:选择字符参数
【名称】:输入参数名称JOB_NAME

3、项目Test_B,输出传入的参数验证。

选择【构建-Execute shell】

输出传参:echo ${JOB_NAME}

4、执行项目Test_A后,自动执行项目Test_B,并传入参数${JOB_NAME},查看项目Test_B输出结果。

项目Test_B输出结果如下:


三、预定义参数

我选择的参数为预定义参数Predefined parameters,那分别有哪些预定义参数可以用呢?

在Build模块下选择Execute shell--the list of available environment variables 选项,可以查看预定义参数信息,如下图:

如下,列出所有可用的预定义参数:

The following variables are available to shell scripts

BRANCH_NAME
For a multibranch project, this will be set to the name of the branch being built, for example in case you wish to deploy to production from master but not from feature branches; if corresponding to some kind of change request, the name is generally arbitrary (refer to CHANGE_ID and CHANGE_TARGET).

CHANGE_ID
For a multibranch project corresponding to some kind of change request, this will be set to the change ID, such as a pull request number, if supported; else unset.

CHANGE_URL
For a multibranch project corresponding to some kind of change request, this will be set to the change URL, if supported; else unset.
___

CHANGE_TITLE
For a multibranch project corresponding to some kind of change request, this will be set to the title of the change, if supported; else unset.
___

CHANGE_AUTHOR
For a multibranch project corresponding to some kind of change request, this will be set to the username of the author of the proposed change, if supported; else unset.
___

CHANGE_AUTHOR_DISPLAY_NAME
For a multibranch project corresponding to some kind of change request, this will be set to the human name of the author, if supported; else unset.
___

CHANGE_AUTHOR_EMAIL
For a multibranch project corresponding to some kind of change request, this will be set to the email address of the author, if supported; else unset.
___

CHANGE_TARGET
For a multibranch project corresponding to some kind of change request, this will be set to the target or base branch to which the change could be merged, if supported; else unset.
___

BUILD_NUMBER
The current build number, such as "153"
___

BUILD_ID
The current build ID, identical to BUILD_NUMBER for builds created in 1.597+, but a YYYY-MM-DD_hh-mm-ss timestamp for older builds
___

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".
___

JOB_BASE_NAME
Short Name of the project of this build stripping off folder paths, such as "foo" for "bar/foo".
___

BUILD_TAG
String of "jenkins-${JOB_NAME}-${BUILD_NUMBER}". All forward slashes ("/") in the JOB_NAME are replaced with dashes ("-"). 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 agent if the build is on an agent, 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)
___

GIT_COMMIT
The commit hash being checked out.
___

GIT_PREVIOUS_COMMIT
The hash of the commit last built on this branch, if any.
___

GIT_PREVIOUS_SUCCESSFUL_COMMIT
The hash of the commit last successfully built on this branch, if any.
___

GIT_BRANCH
The remote branch name, if any.
___

GIT_LOCAL_BRANCH
The local branch name being checked out, if applicable.
___

GIT_URL
The remote URL. If there are multiple, will be GIT_URL_1, GIT_URL_2, etc.
___

GIT_COMMITTER_NAME
The configured Git committer name, if any.
___

GIT_AUTHOR_NAME
The configured Git author name, if any.
___

GIT_COMMITTER_EMAIL
The configured Git committer email, if any.
___

GIT_AUTHOR_EMAIL
The configured Git author email, if any.
___

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.
----
以上~ 如果对你有帮助的话,点赞❤️吧~~

Jenkins- job之间传参的更多相关文章

  1. jsp之间传参中文乱码问题

    jsp页面之间传参,传中文会出现乱码问题. 如下: $('.yzjjfa_row').eq(0).append('<a class="yzjjfa_contItem jjfa_acti ...

  2. jsp页面之间传参用el表达式获取

    jsp页面之间传参用el表达式获取 参数方法:${param.参数名} session方法:${session.变量名}

  3. action之间传参为中文;type='redirect'和 type='redirectAction'主要区别

    摘录自:http://blog.csdn.net/lhi705/article/details/7446156 Struts2中action之间传参中文乱码的问题 解决方法一(已经验证,可以): 两个 ...

  4. ASP.Net内置对象之网页之间传参(一)

    Response对象 主要运用于数据从服务器发送到浏览器,可以输出数据.页面跳转.各个网页之间传参数等操作. 以下讲解几个常用例子: 在页面中输出数据 主要通过Write .WriteFile方法输出 ...

  5. 纯html页面之间传参

    //页面引入//传参方法,可解析url参数 (function($){ $.getUrlParam = function(name) { var reg = new RegExp("(^|& ...

  6. Vue.js父与子组件之间传参

    父向子组件传参 例子:App.vue为父,引入componetA组件之后,则可以在template中使用标签(注意驼峰写法要改成componet-a写法,因为html对大小写不敏感,component ...

  7. LigerUI子父窗口之间传参问题

    在父窗口自定义一个参数,该参数为一个方法,然后在子窗口使用 var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)该对象,取得父窗口定 ...

  8. 微信小程序6 - 页面之间传参及通知系统封装

    1. 简单传参 wx.navigateTo({ url: '/pages/demo/index/index?id=1' }) /pages/demo/index/index.js 中 onLoad(o ...

  9. 前台VUE的组件之间传参方式

    路由传参 """ 转跳: <router-link :to="'/course/'+course.id">{{course.name}}& ...

随机推荐

  1. [20180808]exists and not exists.txt

    [20180808]exists and not exists.txt --//生产系统遇到的一个性能问题,通过例子来说明: 1.环境:SCOTT@test01p> @ ver1 PORT_ST ...

  2. SQL Server -- 回忆笔记(二):增删改查,修改表结构,约束,关键字使用,函数,多表联合查询

    SQL Server知识点回忆篇(二):增删改查,修改表结构,约束,关键字使用,函数,多表联合查询 1. insert 如果sql server设置的排序规则不是简体中文,必须在简体中文字符串前加N, ...

  3. C# WINFORM 应用程序动态读写xml config文件,获取数

    在实际项目里,我们需要用一个应用程序去连接多个数据库,有的进行测试,有的是数据库基本结构相同,数据不同, 我们不可能总去程序的连接字符串里去修改,更不能让用户去修改,所以需要动态去修改连接数据库配置信 ...

  4. 学习flying logic

    之前在知乎上结识的朋友吴笛,他的qq空间里分享了  flying logic的一些用途,我想到可以规划和团队的目标,这点让我感到很兴奋,分享学习这个软件. 学习之前,我应当把软件中的单词学明白.现在就 ...

  5. VMare Workstation 安装Ubuntu 虚拟机教程

    1.VMware Workstation,选择左上角文件—新建虚拟机,开始新建一台虚拟机,典型的话许多配置为默认设置,因此,这里我选择自定义安装: 2.机硬件兼容性选择默认即可: 3.客户操作系统选择 ...

  6. 如何写 go 代码 (How to Write Go Code 翻译)

    目录 1. 写在前面的话 2. 介绍 3. 代码组织 3.1. 工作区 3.2. GOPATH 环境变量 3.3. Package 路径 3.4. 第一个 GO 程序 3.5. 第一个 GO 库 3. ...

  7. Linux 小知识翻译 - 「日志」(log)

    这次聊聊「日志」. 「日志」主要指系统或者软件留下的「记录」.出自表示「航海日志」的「logbook」. 经常听说「出现问题的时候,或者程序没有安装自己预期的来运行的时候,请看看日志!」. 确实,记录 ...

  8. Spark Streaming和Kafka整合保证数据零丢失

    当我们正确地部署好Spark Streaming,我们就可以使用Spark Streaming提供的零数据丢失机制.为了体验这个关键的特性,你需要满足以下几个先决条件: 1.输入的数据来自可靠的数据源 ...

  9. JavaScript在网页中使用以及注意事项

    <script>标签的解析<script>xxx</script>这组标签,是用于在 html 页面中插入 js 的主要方法.它主要有以下几个属性:charset: ...

  10. 【ZJOI2016】线段树

    [ZJOI2016]线段树 ZJOI的题神啊. 我们考虑计算每个位置\(p\),它在操作过后变成第\(x\)个数的操作序列数. 我们枚举\(x\).我们先得到了\(L_x,R_x\)表示最左边比\(x ...