简体   繁体   English

Jenkins-检测工件版本更改

[英]Jenkins - detect artifact version change

I have a simple Maven project that has to produce artifact eg some-artifact I also have a job in Jenkins that does simple maven deploy to our internal Nexus repository. 我有一个简单的Maven项目,该项目必须产生工件,例如一些工件,我在Jenkins也有一份工作,可以将简单的maven部署到我们的内部Nexus存储库中。 This is the value set in Jenkins in "Maven goals and options" field for the job: 这是詹金斯在“ Maven目标和选项”字段中为作业设置的值:

clean source:jar deploy

Lets assume that the version of my maven module is 1.0: 假设我的Maven模块的版本为1.0:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>some.group</groupId>
    <artifactId>some-artifact</artifactId>
    <version>1.0</version>
</project> 

Now, what I want to achieve is to detect that the artifact version is changed in SCM and to build this job each time version number is changed, eg after it is set to 1.1: 现在,我要实现的是检测工件版本在SCM中已更改,并在每次版本号更改时(例如在将其设置为1.1后)构建此作业:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>some.group</groupId>
        <artifactId>some-artifact</artifactId>
        <version>1.1</version>
</project>

The final goal is to have last version of some-artifact deployed on Nexus as soon as possible. 最终目标是尽快在Nexus上部署某些工件的最新版本。

Is there any configuration or Jenkins plugin that allows such detection and job trigger? 是否有任何配置或Jenkins插件允许这种检测和作业触发?

I don't know if it could help, there are several plugin that integrate maven and Jenkins, so maybe one of them will have a build int feature to accomplish you need... 我不知道是否有帮助,有几个插件将maven和Jenkins集成在一起,所以也许其中一个将具有build int功能来满足您的需要...

By the way doing this without a specific plugin there are many ways..You can use the ${POM_VERSION} variable, which was introduced with 通过不使用特定插件的方式进行操作有多种方法。您可以使用$ {POM_VERSION}变量,该变量随

https://issues.jenkins-ci.org/browse/JENKINS-18272 https://issues.jenkins-ci.org/browse/JENKINS-18272

Then compare it with the previous one, the previous revision or an history and so on...This way you can run the job just if the version has been changed. 然后将其与上一个版本,上一个修订版本或历史记录等进行比较...这样,即使版本已更改,也可以运行作业。

You also can use this parameter in combination with the parameterized trigger plugin : 您还可以将此参数与参数化触发器插件结合使用:

https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin

Or you can accomplish this with a SVN hook, something like if the version has been changed trigger a Jenkins job, there could be a lot of ways to do this manually... Very bad this last option! 或者,您也可以使用SVN挂钩来完成此操作,例如,如果更改了版本会触发Jenkins作业,则可能有很多方法可以手动执行此操作……很遗憾,最后一个选择! But it works.. 但这有效。

Let's try to do this in a standard way "user2310395"... 让我们尝试以标准方式“ user2310395”执行此操作...

How do you release you artifact? 您如何释放工件? Maven release plugin or what else? Maven发布插件还是什么?

I'm asking this because i think that a standard "workflow" should be like below: 我问这个问题是因为我认为标准的“工作流程”应如下所示:

  1. Release an artifact (1.00-SNAPSHOT) to (1.00), using the maven release plugin.. Now as you know, this is just about to call a Maven goal, so why don't use Jenkins job to accomplish this? 使用maven发行插件将工件(1.00-SNAPSHOT)释放为(1.00)。现在,您知道,这只是一个Maven目标,所以为什么不使用Jenkins的工作来实现这一目标呢? And you have plugin that help you with this, in case you need, for example: Jenkins Release plugin 而且,如果需要,您可以使用插件来解决此问题,例如:Jenkins Release插件
  2. Once the Release job will run you won't need any other job, because the Maven release plugin itself will take care about the new release artifact into the Nexus tag repository.. 一旦发布作业运行,您将不需要任何其他作业,因为Maven发布插件本身将负责将新发布工件放入Nexus标签存储库中。

So what am i missing, why can't you just follow the standard workflow? 那么我想念的是什么,为什么您不能仅仅遵循标准的工作流程?

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

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