I'm trying to add an asset to a GitLab release but I keep getting {"message":"404 Project Not Found"}
when trying to add a link. I was trying to follow https://docs.gitlab.com/13.7/ee/api/releases/links.html#create-a-link, but I am either crazy or missing something. I have echoed the URLs for both ${PACKAGE_REGISTRY_URL}/${PKG_VERSION}/${LINUX}
and ${RELEASE_REGISTRY_URL}/${CI_PROJECT_ID}/releases/v${PKG_VERSION}/assets/links
and both are valid, and appear to be correct, links. If I use the first one (PACKAGE_URL
) then I get a download of the file that I am wanting. If I use the (RELEASE_REGISTRY_URL
) then I get a page that shows an empty array.
I have also verified that all variables do have the correct values that I would be expecting. I have tried with and without the link_type
option.
# This works with no problem
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file bin/${LINUX} "${PACKAGE_REGISTRY_URL}/${PKG_VERSION}/${LINUX}"
# This returns: {"message":"404 Project Not Found"}
curl --request POST \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--data link_type="other" \
--data name="${LINUX}" \
--data url="${PACKAGE_REGISTRY_URL}/${PKG_VERSION}/${LINUX}" \
--data filepath="bin/${LINUX}" \
"${RELEASE_REGISTRY_URL}/${CI_PROJECT_ID}/releases/v${PKG_VERSION}/assets/links"
"${PACKAGE_REGISTRY_URL}/${PKG_VERSION}/${LINUX}" -> # https://gitlab.com/api/v4/projects/<myidishere>/packages/generic/test/1.1.0/test-1.1.0-linux
"${RELEASE_REGISTRY_URL}/${CI_PROJECT_ID}/releases/v${PKG_VERSION}/assets/links" -> # https://gitlab.com/api/v4/projects/<myidishere>/releases/v1.1.0/assets/links
Here is the example that is in the GitLab documentation.
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--data name="hellodarwin-amd64" \
--data url="https://gitlab.example.com/mynamespace/hello/-/jobs/688/artifacts/raw/bin/hello-darwin-amd64" \
--data filepath="/bin/hellodarwin-amd64" \
"https://gitlab.example.com/api/v4/projects/20/releases/v1.7.0/assets/links"