Child pages
  • Maven Artifact ChoiceListProvider Plugin
Skip to end of metadata
Go to start of metadata

Plugin Information

View Maven Artifact ChoiceListProvider (Nexus) on the plugin site for more information.

Older versions of this plugin may not be safe to use. Please review the following warnings before using an older version:

This Plugin adds an additional ChoiceListProvider to famous Extensible Choice Parameter Plugin to select Artifacts from any Nexus or Maven Central Repository.

MavenArtifact ChoiceListProvider

What is this?

This Plugin adds an additional ChoiceListProvider to famous Extensible Choice Parameter Plugin.

With this extension its possible to use the Service API from a Maven Repositories like Nexus, Maven-Central or Artifactory to search for artifacts using groupId, artifactId and packaging.

This plugin will let the user choose a version from the available artifacts in the repository and will publish the URL as an environment variable. The Plugin will return the full URL of the choosen artifact, so that it will be available during the build, i.E. you can retrieve the artifact by using "wget"

Example

We are using this plugin to let our QA department choose between the various versions of our software which then is downloaded and installed on the test environment.

Configuration Example

Knowns Issue

Nexus 3

Since Nexus 3.15.x the RESTful search service is available by a different URL. In the current plugin version this new URL is used. If you are using an older Nexus 3 instance you have to use the plugin in version 1.3.4

Nexus Snapshots

If you would like to use Snapshot Versions of your artifacts you have to enable the tick-box in the Jenkins Settings. Only with the RESTful interface of Nexus 2 you will be able to retrieve Snapshot versions.

Artifactory

Artifactory API is not returning the correct ArtifactIds but only a URL to a JSON file that contains the DownloadURI of the Artifact. As currently there is no way in the Extensible Choice Plugin to intercept the selected value and because its not performant to query Artifactory for all items in the list for the correct downloadURI, the workaround is like this:

wget `wget -qO - https://repo.jenkins-ci.org/api/storage/releases/org/jenkins-ci/plugins/ant-in-workspace/1.1.0/ant-in-workspace-1.1.0-javadoc.jar | json downloadUri`

The json command like tool is required:

json --version
json 9.0.6
written by Trent Mick
https://github.com/trentm/json

https://github.com/phreakadelle/maven-artifact-choicelistprovider-plugin/issues/11#issuecomment-374142298

Authors

Stephan Watermeyer

License

Licensed  under the MIT License (MIT).

Changelog

07. Februrary 2019 - 1.4.0

  • NEXUS-18345: Migrate to the new RESTful Endpoint
  • Fix: Duplicate entry in global settings

22. December 2018 - 1.3.4

  • FIX: Support more than 50 matches on Nexus 3. Use continuationToken feature.

30. July 2018 - 1.3.2

12. July 2018 - 1.3.1

  • Added Nexus 3 Support
  • Updated Dependency Versions

18. January 2018 - 1.2.3

15. December 2017 - 1.2.2

18. October 2017 - 1.2.0

15. Februar 2017 - 1.1.3

  • FIX: Caching of ChoiceList Parameters leads to the point, that you have to reconfigure the job first before new values are available in the list. This implicit caching is now taken out.

18. Januar 2017 - 1.1.1

  • FIX: Fixed an bug that occured when the URL to the artifact was generated.

17. Januar 2017 - 1.1.0

  • ADD: Added Feature to Support jFrog Artifactory repository.

13. January 2017 - 1.0.4

  • ADD: Implemented a new resolver for artifact items. In the past the URL was constructed to target the file directly in the repository. The new implementation makes use of the RESTful service of Nexus to retrieve an artifact. This has the advantage, that also Snapshot versions can be retrieved. 

23. November 2016 - 1.0.3

  • Finally the official release to jenkins repository

11. November 2016 - 1.0.2

ADD: New dependency to extensible-choice-plugin in version 1.3.3
FIX: POM Update

10. November 2016 - 1.0.1

ADD: New Feature to use the search.maven.org REST API to display artifacts in Jenkins
FIX: Some changes to support the official release of this software

09. November 2016 - 1.0.0

  • ADD: Plugin is released as an official Jenkins Plugin
  • FIX: Changed unit tests to use a public nexus for testing
  • ADD: Prepartion to use shorter artifact names in SelectBox that will be resolved once the build has been started (onBuildTriggeredWith(...)). Only preparation, as i dont have a solution how to change build environments once the build has been started.

25. July 2016 - 0.0.8

  • ADD: Added Configuration to configure UserCredentials for a Nexus Server. Could be a Token or a real Username.

25. July 2016 - 0.0.6

  • ADD: Quickfix to add user credentials for Nexus. Will be put into Jenkins-Credentials in the next version

20. July 2016

  • Changed Implementation of Set containing the results from Nexus to LinkedHashSet as this implementation keeps the order as it is replied from Nexus and also makes sure that entries are only contained once.

29. June 2016

  • Added Checkbox to have the response list in reverse order
  • Changed Packaging-Textbox: Empty Value will only return the parent folder. The * character will return all entries for that artifact. Or use special entries like "tar.gz" or "zip"

30. May 2016

  • Added Example Image showing the Project Configuration
  • Added Comment for the "onBuildTriggeredWith(...)" method which can maybe later extended to transform the provided parameter (which could be a short version of the name) into the correct working URL

24. May 2016

  • Initial Version

7 Comments

  1. for Artifactory, this plugin provides the artifact URI and NOT the download URI, that's quite misleading!

    if you do a wget on the artifact URI, it will dowload the artifact JSON file and not the artifact itself!

    1. Hi Mohamed, please raise an issue on GitHub for this and provide some more information. I think that should be easy to fix. Thanks. Regards Stephan

    2. Hi, Mohamed, please update us if,you're opening an issue about. If you're not going, I can do it. Need same functionality too. 

      Actually I've checked now from my linux machine and it worked OK. 

       

      wget http://artifactory:8081/artifactory/api/storage/Project1/com/mycompany/java/test/2.30/MYPOM.pom

      HTTP request sent, awaiting response... 200 OK
      Length: unspecified [application/vnd.org.jfrog.artifactory.storage.FileInfo+json]
      Saving to: ‘MYPOM.pom’

      [ <=> ] 961 --.-K/s in 0s

      2018-03-07 10:49:38 (90.9 MB/s) - ‘MYPOM.pom’ saved [961]

       

       

  2. Hello the issue is open since 6 days

     

    https://github.com/phreakadelle/maven-artifact-choicelistprovider-plugin/issues/11

     

    we need to get the artifact download URI, and not the artifact URI, in our repo, it was downloading the json file of the artifact and not the zip itself.

  3. Hi, can we use  variable instead of ArtifactID?

     

     

    1. Lets have that discussion within that issue and not on the Wiki Page. 

      So far i am only using Nexus and not Artifactory. I will have to check for your request and see if i can implement it.