How do I promote a build using the REST-API?

Build promotion can be done by using our REST-API query for Build Promotion. This query will require a simple JSON file with the desired details for the promotion, i.e. “targetRepo”, copy artifacts or move them to the destination repository etc.


You can see in our wiki page the set of details required in the JSON file for promoting a build and the REST query for running the promotion.

Here is an example for the REST query, using cURL and the JSON file:


curl -u user:password -H”Content-type:application/json” –data-binary @promote.json -X POST “http://server:port/artifactory/api/build/promote/buildName/buildNumber”

 

JSON file:

{

“status”: “released”,

“ciUser”: “admin”,

“dryRun” : false,

“targetRepo” : “ext-snapshot-local”,

“copy”: false,

“artifacts” : true,

“dependencies” : true,

“scopes” : [ “compile”, “runtime” ],

“properties”: 

  {

   “components”: [“c1″,”c3″,”c14”],

   “release-name”: [“fb3-ga”]

  }

}

 

Please note that the promotion requires a build info file which is part of our build integration feature.

 

In case your build deploys snapshot artifacts, and you are interested in promoting them from snapshot to release artifacts while moving them into another repository, you can use the build-promotion user plugin. This plugin can be found here.

To run this plugin, you will need to put it under the $ARTIFACTORY_HOME/etc/plugins/ folder and enable logger in the $ARTIFACTORY_HOME/etc/logback.xml with the plugin name so this plugin will print into the artifactory.log. For example:


<logger name=”promotion”>

<level value=”info” />

</logger>

 

Once the plugin is set and loaded, you can run the snapshotToRelease promotion by running the Execute Build Promotion REST-API query. For example:


http://repo-demo:8080/artifactory/api/plugins/build/promote/snapshotToRelease/gradle-multi-example/1?params=snapExp=d%7B14%7D|targetRepository=gradle-release-local

 

You can find more information about user plugin and how to setup the plugins here.