Reputation: 161
So I have a Gitlab 8.1 instance running. Everything (nearly) is working as intended. I have deployment and build jobs that execute when I merge to different branches.
But I'd like to create a tarball every time I tag a new version of my project. But I can't seem to figure out the conditions required to trigger that sort of job.
I tag releases in version names (ie. v0.9.1-beta). And I have this in my .gitlab-ci.yml for the project:
build_release:
script:
- composer update
- cd ..
- tar cvzf $CI_BUILD_REF_NAME.tar.gz kin
stage: build
except:
- production
- develop
- ^enhancement\/.*$
- ^feature\/.*$
- ^bugfix\/.*$
But it doesn't trigger. Please help.
Upvotes: 2
Views: 1775
Reputation: 161
I actually found solution myself that works pretty well. Given that all my release tags start with a 'v' followed by a number I was able to do this:
release:
script:
- [BUNCH OF CLEANUP, REMOVAL OF FILES, ETC]
- tar cvzf [APPNAME]_$CI_BUILD_REF_NAME.tar.gz
stage: build
only:
- /v[0-9].*$/
So that was, kinda awesome. :)
Upvotes: 1
Reputation: 31
GitLab
gives you the CI_BUILD_TAG
environment variable. Simply add a test to your script that only creates the tarball
when that environment variable is set.
before_script:
- ... Some before code ...
stage:
stage: stage
script:
- if [ -z "${CI_BUILD_TAG}" ]; then echo "Cowardly refusing to package an un-tagged commit."; exit 0; fi
- ... Script Code Continues if didn't exit ...
Upvotes: 3