How to git tag release with Bitbucket Pipelines (bitbucket-pipelines.yml)

Viewed 6712

How to tag a git commit in pipeline using bitbucket-pipelines.yml file?

1 Answers

Mine script is below. To use it you need to

  1. Add SSH keys in Repo -> Settings -> Pipelines -> SSH keys
  2. Public key add to Team or you Profile SSH keys
- step: &tag
  name: Tag version
  image: atlassian/default-image:2
  script:
    - git remote set-url origin ${BITBUCKET_GIT_SSH_ORIGIN}

    - dt=$(date '+%Y-%m-%d_%H%M');
    - git tag $dt ${BITBUCKET_COMMIT}
    - git push origin --tags

Here you have full documentation of pipeline-git authorization: https://confluence.atlassian.com/bitbucket/push-back-to-your-repository-962352710.html

Related