本文介绍了GitLab:如何将以前工作的工件作为发布资产包含在内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
create:release
任务创建一个新版本.我们如何在任务 create:release
中添加工件 core.zip
?
The task create:release
creates a new release. How do we add the artifact core.zip
in task create:release
?
prepare:release:
stage: prepare_release
before_script:
- echo "Setting up packages for Build"
- apk --no-cache add zip
script:
- echo "Preparing release"
- echo "Build Core"
- yarn --cwd ./core/ install && yarn --cwd ./core/ build
- echo "Zip distribution folder for Core"
- zip -r core.zip ./core/dist ./core/node_modules ./core/package.json
artifacts:
paths:
- core.zip
expire_in: never
create:release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: prepare:release
artifacts: true
variables:
TAG: '$CI_COMMIT_SHA'
script:
- echo "Create Release $TAG"
release:
name: 'Release $TAG'
tag_name: '$TAG'
ref: '$TAG'
description: 'Release $TAG'
推荐答案
我已经解决了.在 prepare:release
作业中,将作业 id 保存在环境文件中,该文件应位于该作业的 artifacts.reports.env
中.稍后,在 create:release
作业中,使用 API "https://gitlab.com/<namespace>/<project_name>/-/jobs/<job_id>/artifacts/download"
来引用工件.
I have resolved this. In prepare:release
job, save the job id in an environment file and this file should be in the artifacts.reports.env
of this job. Later, in the create:release
job, use the API "https://gitlab.com/<namespace>/<project_name>/-/jobs/<job_id>/artifacts/download"
to refer to the artifact.
更新管道:
prepare:release:
stage: prepare_release
before_script:
- echo "Setting up packages for Build"
- apk --no-cache add zip
script:
- echo "Preparing release"
- echo "Build Core"
- yarn --cwd ./core/ install && yarn --cwd ./core/ build
- echo "Zip distribution folder for Core"
- zip -r core.zip ./core/dist ./core/node_modules ./core/package.json
after_script:
- echo "JOB_ID=$CI_JOB_ID" >> job.env
artifacts:
paths:
- core.zip
expire_in: never
reports:
dotenv: job.env
create:release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: prepare:release
artifacts: true
variables:
TAG: '$CI_COMMIT_SHA'
script:
- echo "Create Release $TAG"
- echo $JOB_ID
release:
name: 'Release $TAG'
tag_name: '$TAG'
ref: '$TAG'
description: 'Release $TAG'
assets:
links:
- name: "core.zip"
url: "https://gitlab.com/<namespace>/<project_name>/-/jobs/<job_id>/artifacts/download"
这篇关于GitLab:如何将以前工作的工件作为发布资产包含在内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!