简体   繁体   English

Maven通过Hudson发布

[英]Maven release via Hudson

I'm setting up Hudson to use the batch-task plugin to do maven releases to our internal repository. 我正在设置Hudson使用批处理任务插件来对我们的内部存储库进行maven发布。 I'm doing it via: 我是这样做的:

mvn --batch-mode release:prepare
mvn --batch-mode release:perform

I'm interested in other methods people have used and the pros and cons of those methods. 我对人们使用的其他方法以及这些方法的优缺点感兴趣。 Also, any gotchas people have come across. 此外,任何陷入困境的人都会遇到。

I have tended to do the releases always by hand for a few reasons. 由于一些原因,我总是手工完成这些发布。 First if you have to roll back it's easier when you can go back to the original release location and do it. 首先,如果你必须回滚它,当你可以回到原始版本位置并执行它时会更容易。 Secondly because you need to resolve all snapshot dependencies as part of the process. 其次,因为您需要解决所有快照依赖关系作为该过程的一部分。

Our development process has us leaving dependencies external to the current build at the previous release version until a fix requires an upgrade. 我们的开发过程让我们将依赖关系保留在先前版本的当前版本之外,直到修复需要升级。 This means that if I'm releasing Nexus, Maven, etc, then I see snapshots and it means I have to go off and release those first. 这意味着,如果我发布Nexus,Maven等,那么我会看到快照,这意味着我必须首先发布这些快照。 This process isn't really possible to automate since it varies based on what's changed since the last release. 这个过程实际上不可能自动化,因为它根据自上次发布以来的变化而变化。

That said, we have a special machine (at Sonatype it's just a vm) setup only for builds. 也就是说,我们有一个特殊的机器(在Sonatype它只是一个虚拟机)只为构建设置。 This is done to guarantee no environmental changes occur that could influence a build accidentally (like a jdk change). 这样做是为了保证不会发生可能会意外影响构建的环境变化(如jdk更改)。 It also makes it easier for anyone to pick up the release process because it's always ready to go. 它还使任何人都可以更轻松地获取发布流程,因为它随时可以使用。

Recently, a m2release plugin came to my attention. 最近,一个m2release插件引起了我的注意。 Seemed nice. 看起来不错。 Althought, I would have liked my release process to be completely «pom-tweaking-free». 虽然,我希望我的发布过程完全是“免费调整”。 What I mean by that is that we have to provide 4 input parameter to process a complete release: 我的意思是我们必须提供4个输入参数来处理完整版本:

  1. the release version (ex. 1.0.0) 发布版本(例如1.0.0)
  2. the new development version (ex. 1.0.1-SNAPSHOT) 新的开发版本(例如1.0.1-SNAPSHOT)
  3. the release tag in SCM (ex. release-1.0.0 or 1.0.0) SCM中的发布标记(例如发行版1.0.0或1.0.0)
  4. the tag base path in SCM SCM中的标记基本路径

The first 2 have acceptable defaults. 前2个具有可接受的默认值。 The version bumping at the bug-fix version digit is perfectly fine for me. 错误修复版数字的版本对我来说非常好。

Number 4 can be specified in the pom. 可以在pom中指定4号。 It won't change. 它不会改变。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <configuration>
        <tagBase>https://example.com/svn/myProject/releases</tagBase>
    </configuration>
</plugin>

It's the third one that prevent me from a complete automation of a release at the push of a button. 这是第三个阻止我按下按钮完全自动化发布的第三个。 The default release tag label won't do it for us so we have to specify it: 默认的发布标记标签不会为我们这样做,所以我们必须指定它:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <configuration>
        <tag>release-${pom.version}</tag>
        <tagBase>https://example.com/svn/myProject/releases</tagBase>
    </configuration>
</plugin>

Now, while this might be just what I needed, I end up having a svn tag with the -SNAPSHOT at the end. 现在,虽然这可能正是我所需要的,但我最终得到了一个带有-SNAPSHOT的svn标签。 :( So I have to pass the tag parameter in the Hudson job configuration. Furthermore, I have to go change it for each release we make ... which is not exactly what I need. :(所以我必须在Hudson作业配置中传递tag参数。此外,我必须为我们制作的每个版本更改它...这不是我需要的。


So, in the end, having a maven2 type project in hudson + the m2release hudson plugin + the maven release plugin correctly configured is the Mother of all the release process I've seen so far. 所以,最后,在hudson + m2release hudson插件+正确配置的maven发布插件中有一个maven2类型的项目是迄今为止我见过的所有发布过程的母亲。 While not perfect, it saved me a lot tiedous work. 虽然不完美,但它为我节省了大量的工作。

JS. JS。

我们一直在试验Hudson Maven发布插件,虽然我有点挑战它正确地归功于发布,没有像我们的构建文件中硬编码密码这样的恶意。

我总是手动触发一个明显的利弊:-)

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

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