jenkins持續整合go應用

2022-05-31 16:33:11 字數 1602 閱讀 6922

上文講到使用supervisor管理我們的終端應用,這次講一下使用jenkins持續整合

下面分別講一下pipeline裡每乙個段落的含義

agent any   使用任意節點構建
parameters  模組使用引數化構建
environment 指令碼全域性變數
options     指令碼定義引數,超時時間等
stage       每個步驟
checkout    拉取**命令
when        當全域性變數environment的value期待值符合的時候執行steps
post       結束後執行,always代表無論專案是否執行成功都要執行模組裡的內容。常用的還有changed,failure,success,unstable
其他地方大多數使用了ansible和shell命令,比如ansible $ -m shell -a "supervisorctl restart beepkg" 是使用ansible的shell 呼叫$ip的supervisorctl 重啟beepkg佇列

def createversion() "}

pipeline

environment "}

options

stages

}stage(

'打包應用')

steps

}stage(

'備份伺服器檔案')

steps -m file -a "path=$tmpdir state=directory"

ansible $ -m shell -a "

rsync -qa $remotedir/* $tmpdir --exclude=\'logs\'

"'''

} }

stage(

'發布檔案到伺服器

')/go_online-cups-api.tar.gz

'sh label: '', script: '

ansible $ -m synchronize -a "src=$/go_online-cups-api dest=$remotedir delete=no archive=yes compress=yes rsync_opts=--exclude=\'conf\'"'}

}stage(

'重啟supervisor佇列

') -m shell -a "supervisorctl restart beepkg"

'sh label: '', script: '

ansible $ -m shell -a "supervisorctl status beepkg"'}

}stage(

'生成日誌')}}

post(

'send mail

') - build # $ -$!',

body: '$

',to:

'[email protected]')}}

}

執行效果如下:

jenkins持續整合

1.部署 wget o etc yum.repos.d jenkins.repo no check certificate wget o etc yum.repos.d jenkins.repo rpm import 2.vi etc sysconfig jenkins 修改埠號為10080 3.v...

Jenkins 持續整合

1 手動構建 jenkins構建成功後的包存放在 var lib jenkins workspace 專案名 target下 2 自動化構建 這裡選擇push事件觸發 前面步驟一樣 區別在於觸發器不同 選擇 build when a change is pushed to gitlab.gitlab...

Jenkins持續整合 持續反饋

持續反饋是持續整合中不可或缺的乙個環節,當乙個專案在持續整合過程中,由於單元測試 審查等因素導致專案構建失敗時,資訊應該能夠實時準確的通知到相關的人員,以便於責任人能夠快速的處理。反饋就是在正確的時間,以正確的方式,將正確的資訊傳送給正確的人 持續反饋是讓這種反饋資訊自動化 目標化和實時化 持續化 ...