简体   繁体   English

詹金斯项目版本控制

[英]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. 我有一个版本为2.0.1的java项目,现在我们有一个主要版本更改,例如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. 您应该在Global config中定义一个全局变量。 You can find it Manage Jenkins => Configure and you can define global variables under Global properties => Environment variables . 你可以找到Manage Jenkins => Configure ,你可以在Global properties => Environment variables下定义全局Global properties => Environment variables You will be able to use this environment variable in all or your jobs (Eg.: echo "${MY_JAVA_PROJECT_VERISON}" ). 您将能够在所有或您的工作中使用此环境变量(例如: 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 您可以在此站点上看到一些不同的解决方案来定义全局变量: 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 然后只需选中"This build is parametrized"并定义一个或多个参数,然后在每个构建中,您将在左侧菜单栏中找到Parameters

在此输入图像描述

In pipeline job you can access via "${params.paramName}" , params.paramName , etc. , should works also evn.paramName 在管道作业中,您可以通过"${params.paramName}"params.paramName等进行访问,也可以使用evn.paramName

These parameters can be passed also once you will choose to trigger the job remotely - by URL 一旦您选择通过URL远程触发作业,也可以传递这些参数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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