Question

Hi I am having a Jenkins build pipeline like this: 1. builds the app and deploys to Artifactory; 2. runs an SSH exec command on the test server (remote) to download the artifacts and deploys them into the right directory; 3. runs web tests against the test server, if passed, changes the build status in Artifactory to something like pre-staging for further manual UAT testing. My question is, how to change the build status in Artifactory from a Jenkins job. If using Artifactory's RESTAPI is necessary, can someone share an example? Much appreciated!

Was it helpful?

Solution

Yes, REST API is the easiest way. You need to perform a Build Promotion call. Please note it requires Artifactory Pro.
It's a POST request, accepting simple json string, in which only two properties are mandatory: status and ciUser.

The call should look something like this:

curl -X POST -u admin:password -H "Content-Type: application/json" -d '{"status":"tests passed","ciUser":"jenkinsAdmin"}' "http://localhost:8081/artifactory/api/build/promote/buildName/buildNumber"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top