您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本文的实现:
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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。