首页
视频
资源
登录
原
Jenkins 参数构建
4122
人阅读
2021/4/26 15:50
总访问:
2592480
评论:
0
收藏:
0
手机
分类:
Jenkins
![](https://img.tnblog.net/arcimg/hb/3e561bcf71f1462c9fc300d92e4381d5.png) ># Jenkins 参数构建 [TOC] <p style="font-weight: 400;line-height: 1.5;color: #212529;-webkit-tap-highlight-color: transparent;box-sizing: border-box;padding: 0px 20px 20px 20px;border: 1px solid #e9ecef;border-left-width: .25rem;border-radius: .25rem;display: block;border-left-color: #5bc0de;"> 有时在项目构建的过程中,我们需要根据用户的输入动态传入一些参数,从而影响整个构建结果,这时我们可以使用参数化构建。 </p> 参数类型 ------------ <p style="font-weight: 400;line-height: 1.5;color: #212529;-webkit-tap-highlight-color: transparent;box-sizing: border-box;padding: 0px 20px 20px 20px;border: 1px solid #e9ecef;border-left-width: .25rem;border-radius: .25rem;display: block;border-left-color: #5bc0de;"> Jenkins支持非常丰富的参数类型 </p> ```mermaid graph LR A(Jenkins) -->B(任务Job) B(任务Job) -->C(configure) ``` ![](https://img.tnblog.net/arcimg/hb/328ea7d2da3e4b18adeeda552b78a605.png) <p style="font-weight: 400;line-height: 1.5;color: #212529;-webkit-tap-highlight-color: transparent;box-sizing: border-box;padding: 0px 20px 20px 20px;border: 1px solid #e9ecef;border-left-width: .25rem;border-radius: .25rem;display: block;border-left-color: #5bc0de;"> 接下来演示通过输入gitlab项目的分支名称来部署不同分支任务。 </p> 修改与创建分支 ------------ tn>注意我这里前提是已经创建好了一个项目。 ### master 分支 >首先修改`Jenkinsfile`文件,定义一个`branch`变量进行指定不同的分支(注意修改url的地址) ```groovy pipeline { agent any stages { stage('pull code') { steps { git branch: '${branch}', credentialsId: '771a6f14-71ca-4316-a1a7-d349b005de79', url: 'ssh://git@xx.xx.xx.xx:xx/root/beta.git' } } stage('Read 1.txt') { steps { sh 'cat 1.txt' } } } } ``` >进行提交上传 ```bash echo '这里是 Master 分支' > 1.txt git add . git commit -m 'update 1.txt' git push ``` ### 创建v1分支 ```bash git branch v1 git checkout v1 echo '这里是 V1 分支' > 1.txt git add . git commit -m 'update 1.txt' git push --set-upstream origin v1 ``` ![](https://img.tnblog.net/arcimg/hb/437784fd0e404719bed9695dbf8b0929.png) ![](https://img.tnblog.net/arcimg/hb/577726c46dd54bc798b79a4c32dd56e0.png) ### 创建参数构建 ![](https://img.tnblog.net/arcimg/hb/cbc9972474654d5c8a90ffc0b2d5f227.png) ![](https://img.tnblog.net/arcimg/hb/2e0e0442227645f1adacf154dcf58491.png) 测试 ------------ ### 测试master分支 ![](https://img.tnblog.net/arcimg/hb/7eb4d39903ff47a894bc15d710f2805c.png) ### 测试v1分支 ![](https://img.tnblog.net/arcimg/hb/94c382ec967d4c34806b4e455de35751.png) ![](https://img.tnblog.net/arcimg/hb/110fc9e2907f448eac269fabfb2e176b.png)
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}
尘叶心繁
这一世以无限游戏为使命!
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
.net后台框架
168篇
linux
17篇
linux中cve
1篇
windows中cve
0篇
资源分享
10篇
Win32
3篇
前端
28篇
传说中的c
4篇
Xamarin
9篇
docker
15篇
容器编排
101篇
grpc
4篇
Go
15篇
yaml模板
1篇
理论
2篇
更多
Sqlserver
4篇
云产品
39篇
git
3篇
Unity
1篇
考证
2篇
RabbitMq
23篇
Harbor
1篇
Ansible
8篇
Jenkins
17篇
Vue
1篇
Ids4
18篇
istio
1篇
架构
2篇
网络
7篇
windbg
4篇
AI
18篇
threejs
2篇
人物
1篇
嵌入式
2篇
python
13篇
HuggingFace
8篇
pytorch
9篇
opencv
6篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2024
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
欢迎加群
欢迎加群交流技术