1. 程式人生 > >Jenkins- job之間傳參

Jenkins- job之間傳參

前言:

一、外掛介紹

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的入參的值需要一定邏輯處理才能獲取,那麼,這種傳參方式就特別好用了,比較靈活。
image.png本次傳參例子為:JOB_NAME=${JOB_NAME}

2、專案Test_B,配置-引數化構建過程-配置如下資訊:

選擇【引數化構建過程】

【新增引數-字元引數】:選擇字元引數
【名稱】:輸入引數名稱JOB_NAME
image.png

3、專案Test_B,輸出傳入的引數驗證。

選擇【構建-Execute shell】

輸出傳參:echo ${JOB_NAME}
image.png

4、執行專案Test_A後,自動執行專案Test_B,並傳入引數${JOB_NAME},檢視專案Test_B輸出結果。

專案Test_B輸出結果如下:
image.png

三、預定義引數

我選擇的引數為預定義引數Predefined parameters,那分別有哪些預定義引數可以用呢?

在Build模組下選擇Execute shell--the list of available environment variables 選項,可以檢視預定義引數資訊,如下圖:
image.png

如下,列出所有可用的預定義引數:

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)
___

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之間

前言: 一、外掛介紹 Parameterized Trigger plugin外掛可以讓你在構建完成時觸發新的Job構建,並以各種方式為新Job構建指定引數。 當然也可以新增多個配置:每個配置都有一個要觸發的Job,觸發時間的條件(基於當前構建的結果)和引數部分。 二、使用方法 1、專案Test_A,配

vue,一路走來(12)--父與子之間

今天 component efault 之間 dword return his pre 傳參 今天想起一直沒有記錄父組件與子組件的傳參問題,這在項目中一直用到。 父向子組件傳參 Index.vue父組件中 <component-a :msgfromfa="(posi

小程式三個頁面之間

三個頁面的傳遞引數,這一次我想實現的事我在後臺取到的資料,展現在A頁面傳遞到B頁面展示,B傳遞到C頁面展示。 主要思路:A到B先把B頁面的值取出來並setdada出去   然後在從B傳單C。 主要程式碼: test.wxml       &nb

Jenkins job 之間實現帶引數觸發

1 背景 開發打包的 jenkins job A 是在 local 的一臺 windows 上,同時在這臺 local 的 windows 上還有一 另一個 jenkins job B 是用來上傳 job A 生成的包(build)到測試平臺的倉庫(比如 saucelabs storage)。然而 我們測試

vue中子父、父子之間+雙向

子父傳參vue1.0中 vm.$dispatch 和 vm.$broadcast 被棄用,改用$emit,$onvm.$on( event, callback )監聽當前例項上的自定義事件。事件可以由vm.$emit觸發。回撥函式會接收所有傳入事件觸發函式的額外引數。vm.$

LigerUI子父窗口之間問題

log -m urn 父窗口 頁面 uip ons function 一個 在父窗口自定義一個參數,該參數為一個方法,然後在子窗口使用 var dialog = frameElement.dialog; //調用頁面的dialog對象(ligerui對象)該對象,取得父窗口

Jenkins-job之間依賴關係配置

使用場景: 想要在某APP打新包之後,立即執行自動化測試的job來驗證該新包。 比如Job A 執行完執行Job B ,如下圖所示,如何建立依賴呢? 1、配置上游依賴 構建觸發器-配置如下資訊: 選擇【Build after other projects are built】 【Project to w

springmvc controller之間

需求:系統首頁跳轉到已經開發完成的一個controller上 方案:採用RedirectAttributes存放參數,目標controller使用request.getParameter接收 程式碼: @RequestMapping(value="index") publi

vue使用中的父子元件之間的方法

1.父元件傳參到子元件中 父元件中的用法: 1引入元件 import selfAbility from './children/selfAbility'; 2.在元件中申明: components

Jenkins job之間依賴關系配置(聯動構建)

uil 兩種 驗證 測試的 app trigge data log The 使用場景: 想要在某APP打新包之後,立即執行自動化測試的job來驗證該新包。比如Job A 執行完執行Job B ,如下圖所示,如何建立依賴呢? 主要有兩種方法: 1、配置上遊依賴;

c# winform 窗體之間

能夠 運行 你們 之前 style 全局 類對象 detail 初學者 說起winform程序中窗體之間的參數互傳,大家找度娘會找到很多方法:   1、在窗體類中創建全局變量,類型為公開、靜態的;   2、在窗體類中定義狗仔函數;   3、通過實踐來船體參數;   這三種思

巢狀路由之間值,go(-1)並同時

巢狀路由子路由向父路由傳值方式就是父子元件之間的傳值方式,即使用emit。 如果是想看go(-1)的同時傳值,直接到文末 假設現在有路由如下: A是父路由,BC是子路由 { path: '/A', name: 'A', compone

kotlin activity 之間跳轉及

gradle中實現 implementation "org.jetbrains.anko:anko-commons:0.10.3 startActivity(this!!.intentFor<UploadActivity>() .putExtra("",""

html5之間跳轉頁面,獲取資料以及跳轉後就執行頁面的js程式碼

本次解決的內容如標題:html5之間跳轉頁面傳資料以及跳轉後就執行頁面的js程式碼 舉個我的栗子:就是點選視訊圖片描述後,跳轉到播放該視訊的h5,因為跳轉後視訊播放頁面video標籤需要播放地址,一個視訊的話可以寫死地址,多個視訊的話,就要想寫幾十個h5...想想就難受,所以就需要兩個網頁之

iOS開發技巧-Swift版本: 1.UITextView不同頁面之間

看完前面, 我們已經把 iOS 中的常用的控制元件都講完了, 現在我們該來看看怎麼去使用這些控制元件去開發我們的應用了, 現在讓我們來看看: 1.建立工程 建立完工程之後, 我們去到 Main.Storyboard, 佈局我們需要的介面: 我們可以利用 Xcode 的特性, 快速把一

CMD Bat 之間呼叫

a.bat檔案內容: set input=%1% echo 這裡是a.bat 執行程式碼:呼叫a.bat時,傳了引數:%input% pause b.bat檔案內容: %~dp0\a.ba

angular 控制器之間傳遞

<!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="UTF-8"> <title>Title</title>

(原創)js,ajax與springboot之間的兩種方式

目前實現的有兩種傳參方式。請先理解,勿單純複製貼上。 方式一: 前端js: function update(){ var d = {}; d.userId = 30; d.username = "Sunpeng.Guo";

Jenkins Job中的步驟之間傳遞引數

How to pass variable to next step in jenkins job? 我們知道在Jenkins作業中, 步驟中設定的變數是不能被下一步看到的,那麼如何傳遞一個變數到另一個步驟中呢? 可以利用Jenkins cli. 參考: https://wi

父視窗和iframe子視窗之間相互傳遞引數和呼叫函式或方法(url中)

1.父視窗向子視窗傳遞引數: 可以在url中新增引數:2.html?a=1&b=2&c=3 然後在子頁面上可用js解析,提供一個函式: function getQueryStr(sArgName)