简体   繁体   中英

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 BI 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: 在此处输入图片说明

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

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. ie:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM