Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,502,049
Community Members
 
Community Events
180
Community Groups

Pipelines include tag when pushing to master?

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!

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Matt Ryall Atlassian Team Mar 27, 2017

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.

0 votes

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?

TAGS
AUG Leaders

Atlassian Community Events