Is it possible to build a `bitbucket-pipelines.yml` script that appends a tag when pushing to the master branch? I know I can do this when specifically pushing to a tag via the BITBUCKET_TAG environment variable. My current script has this...
master: - step: script: - composer install - composer run-script build - zip -FSr uc-foi-database-${BITBUCKET_TAG}.zip ./ -x@exclude.lst #${BITBUCKET_TAG} is a default BB variable. - curl -u ${BB_AUTH_STRING} -X POST "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"uc-foi-database-${BITBUCKET_TAG}.zip"
However, this results in `uc-foi-database-.zip` and I'd like `uc-foi-database-1.0.0.zip`
Thanks!
Community moderators have prevented the ability to post new answers.
If your commits are already tagged through some other process, you can use git describe to find the most recent tag on the current branch and use that in your script. You can grab it into an environment variable like this:
pipelines: branches: master: - step: script: - ... - export GIT_TAG=`git describe` - zip -FSr uc-foi-database-${GIT_TAG}.zip ./ -x@exclude.lst - ...
If you want to be sure that the tag is on the exact commit running in your pipeline, you could use git describe --exact-match
.
@Matt Ryall This is exactly what I needed. Thanks very much!
For anyone who comes later I ended up using `git describe --tags --abbrev=0` and then changing the file name to ${BITBUCKET_REPO_SLUG} to make the whole thing more generic/portable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure I understand exactly what you're trying to achieve. Do you want to create a new tag every time you push to master? How do you want the name of the tag to be generated?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.