什么是Gitlab CI工件的好字符串密钥



我必须处理禁用工件上传的Gitlab 11实例,这超出了我的控制范围。我有一个Artifactory服务器可用,并想用它来代替工件存储。

我的问题是:

Gitlab版本11环境变量的组合形成了一个唯一标识Gitlab工件的密钥。

理想情况下,字符串应该很容易组成字符串。

下面是一个候选人,但我不确定这是否理想(借口有趣的布局,SO没有表格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        |

改为使用UUID怎么样?这肯定会唯一地识别一个工件。

请参阅如何创建GUID:UUID?

您可以使用.gitlab-ci.yml中的cache属性在作业之间共享UUID,例如:

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)"

如果不能使用UUID,https://docs.gitlab.com/ee/ci/variables/predefined_variables.html列出了预定义的变量,其中包括您列出的变量——如果您每个作业只生成一个工件,那么您可以使用所列出的内容。

最新更新