Search code examples
jenkins-pluginsartifactory

Jenkins Artifactory plugin: Is there a way to specify a replacement POM?


Short form: is there a way, when deploying a Maven project using the Artifactory jenkins plugin, to tell it to deploy, for each module, its respective ./target/pom.xml rather than the module's original pom.xml?

I have a Maven build with a parent and some child modules that build JARs. The respective POMs are heavily parameterized, so that I can pass in the project.version from Jenkins and that carries down into the child modules, but the parameterized POM files don't work when pulling the JARs for use as dependencies because Maven can't resolve the parent due to the parameterization (<parent><version>${revision}</version></parent> fails badly). I'm able to use the resources plugin in each module to create a filtered version of the POM in ./target with the parameters all resolved, and in the maven-install-plugin in each child POM I can use

<executions>
    <execution>
        <phase>install</phase>
        <goals>
                <goal>install-file</goal>
        </goals>
        <configuration>
                <file>./target/${project.artifactId}-${revision}.jar</file>
                <pomFile>./target/pom.xml</pomFile>
        </configuration>
    </execution>
</executions>

which installs what I want to the local repo. But, I don't see a way to define something like that for the deploy goal in the Jenkins plugin. Is there?


Solution

  • Have you tried to combine maven plugins to see if this could work?

    Run your build that produces the filled in ./target/pom.xml

    i.e. maven exec plugin to:

    1. copy pom.xml to pom.xml.org
    2. move the ./target/pom.xml into ./pom.xml

    Then use the artifactory jenkins plugin w/ the filled in pom.xml

    Then in your post-build steps move ./pom.xml.org back to ./pom.xml to eliminate pollution.