0

I have to work with Gitlab 11 instances that have artifact upload disabled and this is beyond my control. I have an Artifactory server available and want to use it as a replacement for artifact storage.

My question is:

What Gitlab Version 11 environment variables combined form a key that uniquely identifies a gitlab artifact.

Ideally, the strings should be easily should easily make up a string.

Below is a candidate, but I am not sure this is ideal (excuse funny layout, SO has no tables AFAIK):

| Variable        | GitLab | Runner | Description                                           |
|-----------------|--------|--------|-------------------------------------------------------|
| CI_SERVER_NAME  | all    | all    | The name of CI server that is used to coordinate jobs |
| CI_PROJECT_PATH | 8.10   | 0.5    | The namespace with project name                       |
| CI_JOB_NAME     | 9.0    | 0.5    | The name of the job as defined in .gitlab-ci.yml      |
| CI_COMMIT_SHA   | 9.0    | all    | The commit revision for which project is built        |
Jörn Guy Süß
  • 1,408
  • 11
  • 18

1 Answers1

0

How about using a UUID instead? That's sure to uniquely identify an artifact.

See How to create GUID / UUID?

You an share the UUID across jobs with the cache attribute in .gitlab-ci.yml, for example:

image: ubuntu

stages:
- uuidgen
- show-uuid

cache:
 paths:
   - uuid.txt

mk_uuid:
  stage: uuidgen
  script:
    - apt-get update
    - apt-get install -y uuid-runtime
    - uuidgen > uuid.txt

myjob_1:
  stage: show-uuid
  script:
   - echo my UUID is "$(cat uuid.txt)"

myjob_2:
  stage: show-uuid
  script:
   - echo my UUID is "$(cat uuid.txt)"

If you can't use an UUID, https://docs.gitlab.com/ee/ci/variables/predefined_variables.html lists predefined variables, which includes the variables you listed -- if you are only producing one artifact per job, you'll be fine with what you listed.

Aleksey Tsalolikhin
  • 1,518
  • 7
  • 14
  • The context is not carried between build phases, so I would not have a chance of picking it up again. Also, the artifactory schema requires a certain layout. – Jörn Guy Süß May 14 '20 at 04:25
  • Okay. I've updated my answer to show how to carry a UUID between build phases. What layout does the Artifactory schema require? – Aleksey Tsalolikhin May 14 '20 at 16:54