參數(shù)化構(gòu)建
不用過(guò)多解釋,一看就會(huì)蓝晒。這里將主要討論復(fù)雜的參數(shù)化構(gòu)建。
普通的參數(shù)化構(gòu)建
Jenkins參數(shù)化構(gòu)建以使用鍵/值對(duì)
Ensure you have the Active Choices Plugin installed.
確保已安裝了 Active Choices | Jenkins plugin 插件昌讲。
Open the configuration of your Jenkins job, select This project is parameterised.
打開Jenkins作業(yè)的配置,選擇此項(xiàng)目已參數(shù)化重归。
Click Add Parameter and select Active Choices Parameter.
單擊添加參數(shù),然后選擇活動(dòng)選擇參數(shù)米愿。
Name your parameter ENVIRONMENT and click the Groovy Script check box.
將參數(shù)命名為ENVIRONMENT,然后單擊Groovy Script復(fù)選框。
In Groovy Script enter content: return ['env1 file path value':'Test env1', 'env2 file path value':'Test env2'] For this example the user will see a dropdown with 2 options: Test env1 and Test env2. The keys: env1 file path value and env2 file path value are what the Jenkins build parameter will be set to if the option is selected. Modify these as necessary.
在Groovy腳本中輸入內(nèi)容:return ['env1文件路徑值':'測(cè)試env1','env2文件路徑值':'測(cè)試env2']對(duì)于此示例,用戶將看到一個(gè)包含2個(gè)選項(xiàng)的下拉列表:測(cè)試env1和測(cè)試env2 鼻吮。鍵:env1文件路徑值和env2文件路徑值是如果選擇該選項(xiàng),Jenkins構(gòu)建參數(shù)將設(shè)置為的值育苟。根據(jù)需要修改這些。
Jenkins 配置 maven
全局工具配置-Maven 安裝-新增 Maven - 自動(dòng)安裝
遇到過(guò)的問(wèn)題
jenkins 無(wú)法連接倉(cāng)庫(kù):Command /usr/bin/git ls-remote -h
提示的是被拒絕了椎木,我這邊就是因?yàn)橘~號(hào)密碼錯(cuò)誤
mvn 構(gòu)建過(guò)程中報(bào) error:Fatal error compiling: invalid target release: 11
jenkins 全局設(shè)置中指定 jdk 的 home 路徑即可
參考
Jenkins參數(shù)化構(gòu)建以使用鍵/值對(duì) - Jenkins Parameterized build to use key/value pairs - 開發(fā)者知識(shí)庫(kù)
https://www.itdaan.com/blog/2015/05/06/81e6ab41982ea982480d1d23ab43a185.html