您好,登錄后才能下訂單哦!
本文的實現:
gitlab
pipeline
系統管理 - 系統設置 - gitlab
Enable authentication for '/project' end-point
Connection name
和Gitlab host URL
Gitlab API token
登錄用戶 - User settings - Access Tokens
,創建一個Token記錄Test Connection
測試
Success
多分支流水線
Git
Username with Password
Private
,這個用戶必須是這個項目的成員參考 Jenkinsfile Demo
主要配置:
// 獲取gitlab connection, 填寫我們之前配置gitlab connection
properties([gitLabConnection('gitlab-bigdata')])
// 拉取代碼
checkout scm
// 告訴gitlab job狀態
updateGitlabCommitStatus name: 'build', state: 'pending'
// 根據不同的分支觸發不同的步驟
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'dev' ) {
stage("Build Docker Image"){
echo "build docker image"
echo "Only dev/master branch can build docker image"
}
if(env.BRANCH_NAME == 'dev'){
stage("Deploy to test"){
echo "branch dev to deploy to environment test"
}
stage("Integration test"){
echo "test環境集成測試"
}
}
if(env.BRANCH_NAME == 'master'){
stage("Deploy to prod"){
echo "branch master to deploy to environment prod"
}
stage("Health check"){
echo "prod檢查"
}
}
}
管理中心 - 設置 - 網絡 - 外發請求(Admin Area - settings - Network - Outbound requests)
Allow requests to the local network from hooks and services
, 保存Gitlab trigger
Settings - Integrations
Push events
和Merge request events
http://JENKINS_URL/project/PROJECT_NAME
When you configure the plugin to trigger your Jenkins job, by following the instructions below depending on job type, it will listen on a dedicated URL for JSON POSTs from GitLab's webhooks. That URL always takes the form http://JENKINS_URL/project/PROJECT_NAME, or http://JENKINS_URL/project/FOLDER/PROJECT_NAME if the project is inside a folder in Jenkins. You should not be using http://JENKINS_URL/job/PROJECT_NAME/build or http://JENKINS_URL/job/gitlab-plugin/buildWithParameters, as this will bypass the plugin completely.
Settings - Integrations
Recent Deliveries
部分,顯示了最近的Trigger狀態200
passed
成功
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。