网站首页 > 技术文章 正文
7. 基于Jenkinsfile进行流水线发布:
在Jenkins中用pipeline流水线发布,确实很方便。但是存在不好维护,版本控制难的问题。
# 在项目的根文件目录下创建Jenkinsfile文件:
[root@node1 jpress]# pwd
/data/objects/jpress
# 把Jenkins中pipeline的脚本放到该文件中:
[root@node1 jpress]# vim Jenkinsfile
pipeline {
agent any
stages {
stage('pull jpress') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: '7be513bf-758a-49b1-8e5b-b0dad901ac95', url: 'http://192.168.75.121/dev1_group/jpress.git']]])
}
}
stage('build jpress') {
steps {
sh 'mvn clean package'
}
}
stage('deploy jpress') {
steps {
deploy adapters: [tomcat9(credentialsId: 'bc20512e-12cf-485c-b5f4-0254d3e7b004', path: '', url: 'http://192.168.75.123:8080/')], contextPath: null, war: '*/target/*.war'
}
}
}
}
# 推送到gitlab的jpress项目:
[root@node1 jpress]# git add .
[root@node1 jpress]# git commit -m "add Jenkinsfile"
[master c8321a5] add Jenkinsfile
1 file changed, 21 insertions(+)
create mode 100644 Jenkinsfile
[root@node1 jpress]# git push
warning: push.default 未设置,它的默认值将会在 Git 2.0 由 'matching'
修改为 'simple'。若要不再显示本信息并在其默认值改变后维持当前使用习惯,
进行如下设置:
git config --global push.default matching
若要不再显示本信息并从现在开始采用新的使用习惯,设置:
git config --global push.default simple
参见 'git help config' 并查找 'push.default' 以获取更多信息。
('simple' 模式由 Git 1.7.11 版本引入。如果您有时要使用老版本的 Git,
为保持兼容,请用 'current' 代替 'simple' 模式)
Username for 'http://192.168.75.121': xiaoming
Password for 'http://xiaoming@192.168.75.121':
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 628 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To http://192.168.75.121/dev1_group/jpress.git
4099ceb..c8321a5 master -> master
[root@node1 jpress]#
7.1 Jenkins配置pipeline:
7.2 开始构建:
7.3 部署完成;
到此已经基于Jenkins实现了基于Jenkinsfile文件的流水线方式构建项目。
欢迎点赞,收藏,你的喜欢就是我原创的动力,Jenkins系列将会持续更新。
如果获取最新文章更新,以及常用软件,可以关注公众号: 笨办法学linux
猜你喜欢
- 2025-07-07 公司代码在内网的gitlab上,但是又想访问github,该怎么配置呢?
- 2025-07-07 Git分布式版本控制器常用命令和使用
- 2025-07-07 macbook 上安装git和将github作为托管服务器
- 2025-07-07 Git基本使用,分布式版本控制(git fench)
- 2025-07-07 手把手教你如何上传代码到gitee服务器
- 2025-07-07 从零打造自己的 国产鸿蒙(OpenHarmony)定制系统-完整可落地流程
- 2025-07-07 「工具」代码管理工具Git(git源代码管理工具)
- 2025-07-07 掌握git命令,图解一目了然(掌握git命令,图解一目了然的步骤)
- 2025-07-07 Git 2.47发布:引入增量多包索引、自动合并VS Code配置等
- 2025-07-07 Git安装避坑指南(git安装过程)
- 1509℃桌面软件开发新体验!用 Blazor Hybrid 打造简洁高效的视频处理工具
- 530℃Dify工具使用全场景:dify-sandbox沙盒的原理(源码篇·第2期)
- 493℃MySQL service启动脚本浅析(r12笔记第59天)
- 473℃服务器异常重启,导致mysql启动失败,问题解决过程记录
- 470℃启用MySQL查询缓存(mysql8.0查询缓存)
- 451℃「赵强老师」MySQL的闪回(赵强iso是哪个大学毕业的)
- 430℃mysql服务怎么启动和关闭?(mysql服务怎么启动和关闭)
- 427℃MySQL server PID file could not be found!失败
- 最近发表
- 标签列表
-
- c++中::是什么意思 (83)
- 标签用于 (65)
- 主键只能有一个吗 (66)
- c#console.writeline不显示 (75)
- pythoncase语句 (81)
- es6includes (73)
- windowsscripthost (67)
- apt-getinstall-y (86)
- node_modules怎么生成 (76)
- chromepost (65)
- c++int转char (75)
- static函数和普通函数 (76)
- el-date-picker开始日期早于结束日期 (70)
- js判断是否是json字符串 (67)
- checkout-b (67)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- & (66)
- java (73)
- js数组插入 (83)
- linux删除一个文件夹 (65)
- mac安装java (72)
- eacces (67)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)