API to download the latest release assets
### Summary There is no API to download the latest version of release assets ### Details Relates to, but not the same as: * https://gitlab.com/gitlab-org/gitlab/-/issues/343223+ * https://gitlab.com/gitlab-org/gitlab/-/issues/28978#note_899985341 * https://gitlab.com/gitlab-org/gitlab/-/issues/25838+ * https://gitlab.com/gitlab-org/gitlab/-/issues/16821#note_900665762 I have a CI pipeline that uploads a file to the generic package repository: ``` bash curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file myfile.txt "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PKG}/${VERSION}/myfile.txt" ``` And references it in a release as link asset ``` - name: 'myfile' url: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PKG}/${VERSION}/myfile.txt" filepath: '/myfile.txt' link_type: 'other' ``` This works fine and I can visit https://gitlab.com/${CI_PROJECT_PATH_SLUG}/-/releases/permalink/latest/downloads/myfile.txt in a browser to download the latest version of the file, as I'm logged in. If I attempt to download from a CI job using curl and the JOB-TOKEN: ``` bash curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" https://gitlab.com/${CI_PROJECT_PATH_SLUG}/-/releases/permalink/latest/downloads/myfile.txt ``` I get a redirect: ``` <html><body>You are being <a href="https://gitlab.com/users/sign_in">redirected</a>.</body></html> ``` I can work around this by using querying the releases, which are sorted, and accessing the asset link from this: ``` bash latest_pkg_url=$(curl --location --header "JOB-TOKEN: ${CI_JOB_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases" | jq -r '.[0].assets.links[] | select(.name=="My File").url') curl --location --header "JOB-TOKEN: ${CI_JOB_TOKEN}" "${latest_pkg_url}" --output myfile.txt ``` There is `../releases/permalink/latest/downloads/..` in the public gitlab.com web interface, which requires login, but I cannot find an equivalent path in the CI_API_V4_URL API that can be used with curl and a TOKEN from a pipeline. I guess the problem is that `https://gitlab.com/${CI_PROJECT_PATH_SLUG}...` is public web interface and thus wants to redirect to login, and not the API interface. But there appears to be no API interface (`${CI_API_V4_URL}/projects/${CI_PROJECT_ID}...`) to download the latest version of release asset link.
issue