創建git
配置Pipeline Libraries 首先要在gitlab 創建倉庫,如下圖:
配置Jenkins全局配置
系統管理——》全局配置——》Global Pipeline Libraries,配置如下圖:
新建測試pipeline
新建test.groovy,git提交,構建是jenkins會自動引用。
<code>def
call
(
int
a,int
b) {return
a + b }/<code>
新建jenkins job
新建test-pipeline
<code> _ node { stage("test"
) { def aa = test(1
,2
) echo"
${aa}
" } }/<code>
結果:
大家可以根據自己的環境編寫模板,就可以應用到有所有的業務線。運維負責寫方法,把方法使用說明寫好,以後增加什麼都可以推到研發。
如果對您有幫助,記得不要忘了給個關注哦!!!@上海IT故事
還可以關注我之前的文章: