Search code examples
mavenjenkinscontinuous-integrationbuild-processnexus

How can I get the latest version of my nexus artifact into my jenkins batchscript?


I have this below line in a batch script in my Jenkins build job, which downloads a specific artifact from nexus server.

 call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=http://10.101.2.23:8081/nexus/content/repositories/releases/ -Dartifact=test:update-service:1.0.3 -Ddest=Setups/Services/update-service.jar

Here I have hardcoded the latest version available at Nexus. Is it possible to get the latest version available at nexus using a jenkins variable? If so how? Please advice.


Solution

  • use "LATEST" for latest snapshot version or "RELEASE" for latest release version. In your case

    call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=http://10.101.2.23:8081/nexus/content/repositories/releases/ -Dartifact=test:update-service:RELEASE -Ddest=Setups/Services/update-service.jar
    

    so you don't need a jenkins variable to inject a variable.

    since you are using jenkins, my advice is to use the "Artifact Resolver"

    hope this helps.