GitLab CI/CD Release Assets

Describe your question in as much detail as possible:

Hi all -

I’m using GitLab CI/CD to create releases for version control. I’d like to be able to include assets that are not stored on the GitLab instance but as a download link included on that release (does that make sense?). I’ve been trying to implement adding an asset to my releases for quite a while now and it’s just stumping me.

  • What are you seeing, and how does that differ from what you expect to see?

I’m seeing my assets not being included in the release page except for the pre-created release assets such as the source code. In the CI/CD traceback page I get an error implying that I’m attempting to access a GitLab page that doesn’t exist. I’m assuming the format that I’m trying to create an asset is incorrect.

  • What version are you on? Are you using self-managed or GitLab.com?
    Self managed, 13.12.1-ee

  • Add the CI configuration from .gitlab-ci.yml and other configuration if relevant (e.g. docker-compose.yml)

Here’s the line that I use to create the release. I’m following the example from the GitLab docs but using it in a bash script as just attempting to use it in gitlab-ci.yml was more of a headache than I was under the impression it would be.

#!/bin/bash

curl --request POST --header "PRIVATE-TOKEN: XXXXXXXXXX" --data name="test.txt" --data url="MYGITLABINSTANCEURL/$1/-/jobs/$2/artifacts/test.txt" --data filepath="/home/gitadmin/Documents/ci-cd-test/test.txt" "MYGITLABINSTANCEURL/projects/$1/releases/v${MAJOR}.${MINOR}.${REVISION}/assets/links"

$1 is $CI_PROJECT_NAME
$2 is $CI_JOB_ID

  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

There doesn’t seem to be much out there except for the docs I linked earlier.

If there’s questions as to what I’m trying to do I’m happy to answer or provide more context!

Thanks in advance!

The error message would definitely be useful. But I guess MYGITLABINSTANCEURL should be different for the last param https://gitlab.example.com/api/v4/ and url https://gitlab.example.com/

Are you aware of release-cli?

I had my own round of problems with it (call from Powershell with --assets-link does not work as documented (#113) · Issues · GitLab.org / release-cli · GitLab), but in general it should make your task easier.
Also you should not directly link artifacts in such a situation since those are considered temporary. A generic package would be more suitable.

:wave: @jmachcse you could also use the release keyword from the .gitlab-ci.yml file Keyword reference for the `.gitlab-ci.yml` file | GitLab

On the other hand, the release needs to exist before you can create a link via the API Release links API | GitLab