Say I have a repo ci-templates
with all my reused gitlab-ci.yml
templates. I am trying to add a template that generates Release Notes based on the commits between tags. I generate the release notes with a bash script that lives in the ci-templates
repo. The release job uses image registry.gitlab.com/gitlab-org/release-cli
which uses ash
by default but I can install bash
, git
, and a few other tools at the start.
How can I add a bash script in the ci-templates
repo that is pulled in and used during other other CI jobs when the templates is used via
include:
- project: 'ci-templates'
file: 'templates/release-notes.yml'
I tried writing the bash script into the yml file, but script:
is not executed as bash. Would I have to manually call bash on every single line? Is there no cleaner way?
I also tried using $CI_JOB_TOKEN
and the files api to download the file from the repo and then run it via bash script.sh
but this fails since the token does not have api permission to use the file api.
At this point, trying to make this a generic template is more pain than its worth. I'd be more productive just copy pasting the script everywhere, but I'd like to avoid that for the sake of my team. Any ideas here? I think I understand the yaml important, but I have no idea how to reference anything that lives outside of the yaml.
question from:
https://stackoverflow.com/questions/66057191/gitlab-ci-templates-reference-file-script-local-to-the-template 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…