Martin Melka
Martin Melka

Reputation: 7799

Get latest build with a status in Artifactory

I have a Generic repository where we store artifacts from various builds. Our builds have 3 possible states - built, staged, release. Those states are assigned through the REST API Build Promotion call.

In build B I need artifacts of the latest release build A. How do I do that?

The artifacts have structure:

Generic:UNIX/somefolder/123/<artifacts-of-build-id-123>
Generic:UNIX/somefolder/123/<artifacts-of-build-id-124>

What I have tried:

a) The build is run on TeamCity, so I tried using the TeamCity plugin. There I tried this dependency pattern: Generic:UNIX/somefolder/**/*.raw@UNIX :: BuildName :: Build#LAST_RELEASE => build-dir/ -- this did not work. Using LATEST instead of LAST_RELEASE did work, but resolved the very latest build, regardless of its status.

b) Using the REST API: I made this call:

curl -v --fail --request POST --header 'Content-Type: application/json' \
--data '{"buildName": "UNIX :: BuildName :: Build", "buildNumber": "LATEST", "buildStatus": "release"}' \
https://artifactory.srv.int.domain.com/artifactory/api/search/buildArtifacts

But that returns 400 Bad Request error. Removing the "buildStatus" from the JSON helps, but then I, again, get the latest version, regardless of its status.

The build artifacts have those properties: enter image description here

EDIT: I don't have a Custom Layout set up, but I made one for this case to test it out. Did not help.

Upvotes: 1

Views: 984

Answers (1)

Itamarb
Itamarb

Reputation: 111

Using both the "buildNumber": "LATEST" And "buildStatus": "release" parameters might create a conflict between the constraints. Usage of the "buildStatus" parameter is allowed only when not specifying the buildNumber param. i.e:

curl -v --fail --request POST --header 'Content-Type: application/json' \ --data '{"buildName": "UNIX :: BuildName :: Build", "buildStatus": "release"}' \ https://artifactory.srv.int.domain.com/artifactory/api/search/buildArtifacts

Hope this helps, Itamar

Upvotes: 2

Related Questions