How to increase jenkins build number automatically or by using shell script?? For now i am doing the same using configure option, and increasing manually. i want to do it automatically.
相关问题
- Jenkins - cmd is not recognized
- When using Nokogiri, how do you suppress the inser
- Where Jenkins stores plugin configuration
- Multi-branch configuration with externally-defined
- How to start pm2 website using jenkins on AWS ubun
相关文章
- dotnet restore还原nuget包时无法加载 https://api.nuget.org/
- jenkins在window集群环境中如何部署自动化发布?
- jenkins + Publish over FTP 自动部署前端React项目
- jenkins自定打包部署React前端项目遇到的问题。
- Best way to manage docker containers with supervis
- Access BitBucket payload data in Jenkins pipeline
- Jenkins Not Outputting Junit Report Info From File
- Intermittent “SVNException: svn: E175002: Connecti
What you are asking for (i.e. keeping the build number same between multiple jobs) is simply impossible in Jenkins. This is done by design (as noted by Jenkins creator himself):
"[JENKINS] assumes that the build number is unique and monotonic."
. You can change it to a higher value, but changing it to same number will outright break Jenkins and is therefore not possible.Build run number is just that: a run number.
It is supposed to be sequential.
It is not a version number in any way.
There are several ways to get versioning information into the build history however.
Description Setter Plugin
This is what I use. It doesn't change the build number, but rather the description, which is done automatically. Furthermore, since this is a description, it can also be modified manually at any time.
This is what it looks like:
Note that builds
#50
and#51
actually have the same version1.3.0.394376
.In that version string, the
1.3.0
is the current release number, as determined by the project properties, while the394376
is actually an SVN revision number, obtained from$SVN_REVISION_1
build variable. So every time there is a new commit in SVN, I get a new revision number. But if there are no commits and the job is rebuilt for whatever reason (like in#50
and#51
), my version number remains same, as there was no code change.The way I have it configured is:
echo Version is: ${internalVersionNumberFromWherever}.${SVN_REVISION_1}
Version is: (.*)
(.*)
will be used as description.Build - \1
. Where\1
is a reference to first group(.*)
from the RegEx.* Note that if your build fails before the step that outputs the version text, the description setter plugin will not be able to pick it up. If you always want to see the version, then setup the display of version number as the very first step.
Build Name Setter plugin
This plugin will actually change the build number
However remember the limitation that each build number has to be unique.
Best way to ensure that is to add
${BUILD_NUMBER}
to whatever arbitrary number that you want (like in the image above). This way you can have builds numbers like50.123
and then50.124
where50
is your version while123
and124
are sequential build run numbers, and Jenkins makes sure of keeping the${BUILD_NUMBER}
unique.Finally, there is the Version Number plugin which I haven't personally tried, but it may help you.