简体   繁体   English

Hudson / Jenkins发布插件:发布版本问题

[英]Hudson / Jenkins release plugin: release version issues

I am in the process of setting up a new hudson project and stumbled over the release plugin . 我正在建立一个新的hudson项目,偶然发现了release插件 You have basically two possibilities: 您基本上有两种可能性:

  1. Don't define the String Parameters releaseVersion and developmentVersion - then the maven release plugin uses default values. 不要定义字符串参数releaseVersiondevelopmentVersion然后maven release插件使用默认值。 (Eg 1.0.0-SNAPSHOT (svn) -> 1.0.0 version will be released (tag in svn) and 1.0.1-SNAPSHOT will be the next development version.) In most of the cases that is enough for us. (例如,将发布1.0.0-SNAPSHOT(svn)-> 1.0.0版本(在svn中标记),而下一个开发版本将是1.0.1-SNAPSHOT。)在大多数情况下,这对我们足够了。 However in certain cases (eg a major release should be build) it isn't enough. 但是,在某些情况下(例如应构建主要版本),这还不够。
  2. Define those two values (cp. image, red markers) but then you always have to fill them and they are empty! 定义这两个值(cp图像,红色标记),但是您始终必须填充它们,并且它们为空! There is obviously no possibility to use default values or leave them blank. 显然不可能使用默认值或将其保留为空白。 Thats why one has the possibility to add preRelease and postRelease actions like scripts etc. However if the plugin would be slightly more intelligent that wouldn't be necessary imho. 这就是为什么有可能添加preReleasepostRelease操作(如脚本等)的原因。但是,如果插件稍微更智能,那不是不必要的。

在此处输入图片说明

So my question is: Is there a way without using before/after release build scripts to get the wanted behaviour? 所以我的问题是:有没有一种方法可以不使用发布前/发布后的构建脚本来获取所需的行为?

The wanted behaviour is: The fields releaseVersion and developmentVersion should be prefilled with the actual version / version+1. 所需的行为是:字段releaseVersiondevelopmentVersion应该预releaseVersion实际的版本/ version + 1。 If that is not possible then leaving those fields blank also suffice (if that triggers the default behaviour of the maven build plugin) If those fields are blank now, maven will be called with an empty parameter and thus fail. 如果这不可能,那么将这些字段留空也就足够了(如果这触发了maven build插件的默认行为)。如果这些字段现在为空,则将使用空参数调用maven并因此失败。

(In different projects I have used jenkins in combination with the artifactory release plugin which is really easy - If a version should be released a page is show where all the versions are listed. If eg a major version should be build a user can easily change the numbers.) (在不同的项目中,我将jenkins与人工发布插件结合使用,这真的很容易-如果要发布一个版本,则会显示一个页面,其中列出了所有版本。如果要构建一个主要版本,则用户可以轻松更改号码。)

I have had a similar problem, but the solution for me might have some significant overhead in your situation. 我遇到了类似的问题,但是对我来说,解决方案可能会在您遇到的情况中产生一些重大开销。

Jobs in my setup are not created manually but are instead generated using the Job DSL Plugin . 我的设置中的作业不是手动创建的,而是使用Job DSL Plugin生成的。 This is the case because many similar jobs for different artifacts exist and generation tends to stop snowflake jobs from different users. 之所以如此,是因为存在许多针对不同工件的相似作业,并且生成倾向于停止来自不同用户的雪花作业。

My solution looks something like this: 我的解决方案如下所示:

  1. For each job in generation: Query your artifact repository for the latest version of the artifact created by the job (Sonatype Nexus for me) 对于生成的每个作业:在工件库中查询作业创建的工件的最新版本(Sonatype Nexus对我而言)
  2. Generate the versions you want to display to a user (simply add the minor etc) 生成要显示给用户的版本(只需添加次要版本等)
  3. Apply the version as the default-text to your string parameter in Job DSL (As shown here ) 应用版本作为默认文本在工作DSL的字符串参数(如图所示这里
  4. Rerun the generation in a set interval, so the jobs most likely show the correct versions 在设定的时间间隔内重新运行生成,因此作业很可能显示正确的版本

This was easily possible for me, as Job DSL was already in place and the name of each artifact is part of the jobname. 这对我来说很容易实现,因为Job DSL已经存在,并且每个工件的名称都是jobname的一部分。 It is far from perfect, as there can be points in time which do not show the correct version (right after a new release when the job creation hasn't been rerun). 这远非完美,因为有时会显示不正确的版本(在新版本发布后,即未重新创建作业时)。

Another option would be to create a custom Jenkins Plugin for this task, but it would likely carry even more overhead. 另一个选择是为此任务创建一个自定义的Jenkins插件,但可能会带来更多开销。

PS: I can try to include some more code samples if this solutions is a route you want to try. PS:如果此解决方案是您要尝试的方法,则可以尝试包含更多代码示例。

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

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