Jenkins Pipeline
一 初识Pipeline
1.1 创建 Pipeline 任务
创建步骤: 新建任务 -- 定义任务名称 -->> 选择 Pipeline --->> 确定

Pipeline 语法
- 步骤语法 stage


- input 询问 点击确定继续


- 执行脚本
node {
stage('Code Pull'){
echo "Code Pull"
}
stage('Code Build'){
echo 'code build'
}
stage('Unit Test'){
echo 'Unit test'
}
stage('是否部署?'){
input '部署测试环境'
}
stage('Deploy Test ENV'){
sh '/opt/test.sh test' # sh语法
}
}
Jenkins和gitlab集成自动触发
插件: gitlab
设置路径: 系统管理 --->> 系统设置 -->> gitlab
获取 Gitlab Tokens : 右上角管理员 --->> 设置 --->> Access Tokens


jenkins设置


项目设置
dev 分支 提交代码 自动构建



URL token 在填入gitlab 项目中
路径: gitlab项目 --->> settings --->> Integrations (取消ssl认证)

测试
cd test1/ git clone git@172.16.0.111:devops/ops-docs.git cd ops-docs/ git fetch git checkout dev git status echo '123456' >> index.heml git add index.heml git commit -m 'index' git commit -m 'index' git push
作者:闫世成
出处:http://cnblogs.com/yanshicheng
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题或建议,请联系上述邮箱,非常感谢。

浙公网安备 33010602011771号