如果对pipeline语法不熟悉,没关系,我这有一篇传统方法。
1:新建流水线项目
新建项目
2:直接去写pipeline
流水线
模版
pipeline {
agent any
triggers {
gitlab (
triggerOnPush: true, # 当 GitLab 触发 push 事件时,是否执行构建
triggerOnMergeRequest: true, # 当 GitLab 触发 mergeRequest 事件时,是否执行构建
branchFilterType: 'All', # 只有符合条件的分支才会触发构建
secretToken: "abc"
)
}
stages {
stage('build') {
steps {
echo "hello world"
}
}
}
}
3:写好以后去gitlab上直接配webhooks
webhook格式:<jenkins地址:端口>/jenkins/project/<项目名>
image.png
4:git上传新代码
上传代码
5:查看 jenkins 构建历史
效果图