Reputation: 27321
I would like to write an template that is includeable from our global build template and that will copy a repo's static folder to my static server.
The global build template (build.yml):
stages:
- test
- build
- deploy
include:
...
- local: '/ci-templates/publish_static.yml'
which can be used in all repos with (my-app/.gitlab-ci.yml):
include:
- project: 'mycompany/ci-tools'
file: '/ci-templates/build.yml'
Given the repo structure:
my-app
│ .gitlab-ci.yml
└───myapp
└───static
The rule would be something like:
publish_static:
stage: deploy
script:
- export STATIC="$(find . -type d -name static)"
- rsync -rvv $STATIC [email protected]:/www/static
unfortunately, not all repos have a static folder, and I can't find a way to use rules:exists
since the static folder isn't in a subfolder that matches $CI_PROJECT_NAME
.
My attempt to use bash logic:
publish_static:
stage: deploy
script:
- export STATIC="$(find . -type d -name static)"
- '[ -d $STATIC ] && rsync -rvv $STATIC [email protected]:/www/static'
causes the job to fail when [ -d .. ]
fails.
Is there a way to use rules:exists
that I have overlooked? ..or is there a way to make the last command "succeed" even when the $STATIC
directory doesn't exist?
(I've added allow_failure: true
, but we really want the fully green check-icon on our pipelines ;-)
Upvotes: 3
Views: 9254
Reputation: 141473
not all repos have a static folder, and I can't find a way to use rules:exists since the static folder isn't in a subfolder that matches $CI_PROJECT_NAME.
Do:
rules:
- exists:
- '*/static'
See Additional details
in https://docs.gitlab.com/ee/ci/yaml/#rulesexists .
Upvotes: 4