自动化部署之maven项目按版本发布
按版本发布
- 安装git parameter plugin插件
- 任务配置中勾选<参数化构建>
- 选择git parameter
- 创建变量名 release(自定义)
- 选择发布类型:
tag:按标签发布
branch:按分支发布
Revison:按修订发布
- 安装git parameter plugin插件
修改pom.xml中的版本改为v1.0
[[email protected] testing]# vim pom.xml
<version>v1.0</version>
[[email protected] testing]# git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: pom.xml
#
no changes added to commit (use "git add" and/or "git commit -a")
[[email protected] testing]# git add .
[[email protected] testing]# git commit -m "v1.0"
[master eed5815] v1.0
1 file changed, 1 insertion(+), 1 deletion(-)
[[email protected] testing]# git push origin master
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 281 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To [email protected]192.168.56.11:java/Java.git
37d2bd1..eed5815 master -> master
给Java项目中的版本修改后打上标签
此时我们再修改
[[email protected] testing]# vim src/main/java/com/ghz/testweb/App.java
package com.ghz.testweb;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World! i am guo2 v1.0" );
}
}
[[email protected] testing]# git add .
[[email protected] testing]# git commit -m "featrue1"
[master 6402300] featrue1
1 file changed, 1 insertion(+), 1 deletion(-)
[[email protected] testing]# git push origin master
Counting objects: 17, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (9/9), 565 bytes | 0 bytes/s, done.
Total 9 (delta 2), reused 0 (delta 0)
To [email protected]192.168.56.11:java/Java.git
eed5815..6402300 master -> master
此时进行构建,由于版本修改了,会报错:
但是我们每次进行版本的修改后如果都去修改excute shell就显得太麻烦
- 任务配置中勾选<参数化构建>
3.选择git parameter - 创建变量名 release(自定义)
修改源码管理
- 选择发布类型:
tag:按标签发布
6.对代码进行多次修改,并提交
然后再代码库中对提交进行tag标记
再在jenkins中查看,即可按照不同的版本进行构建,如图:
版权声明:原创作品,谢绝转载。否则将追究法律责任
本文转自 IT_外卖小哥 51CTO博客,原文链接:http://blog.51cto.com/jinlong/2053631