简体   繁体   中英

Jenkins Project Versioning

I have a java project with version eg 2.0.1 now we have a major release change eg 3.0.0. what I want is to pass the version of project i want to build as parameter. How can this functionality be achived.

You should define a global variable in Global config. You can find it Manage Jenkins => Configure and you can define global variables under Global properties => Environment variables . You will be able to use this environment variable in all or your jobs (Eg.: echo "${MY_JAVA_PROJECT_VERISON}" ). You can see some different solution to define global variable on this site: https://medium.com/@mukeshsingal/access-jenkins-global-environment-variables-using-groovy-or-java-b5c1e6b53685

You can achieve that eg. by plugin Parametrized build

Then simply check "This build is parametrized" and define one-or-more parameters, afterwards on each build you will find Parameters in the left menu bar

在此输入图像描述

In pipeline job you can access via "${params.paramName}" , params.paramName , etc. , should works also evn.paramName

These parameters can be passed also once you will choose to trigger the job remotely - by URL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM