I would like to create a tagged release for my terraform module using a pipeline step when this get merged to master using a Pull Request.
Something like this.
release_job:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
script:
- echo "running release_job for $TAG"
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: 'v0.$CI_PIPELINE_IID' # The version is incremented per pipeline.
description: 'v0.$CI_PIPELINE_IID'
ref: '$CI_COMMIT_SHA'
Welcome to the community.
If I understand it correctly, you'd like Bitbucket Cloud Pipelines to trigger builds on tag release.
If yes, you can try triggering Pipelines builds by triggering on tags.
You can check this link for more information about triggering Pipelines tags. - Configure bitbucket-pipelines.yml - tags
You can test it out and see if it fits your requirement.
Let me know if you have further questions.
Regards,
Mark C
Hey Mark, thank you for you answer, let me try to explain better.
I need to create a step what will alow me to create a release for whatever I have in my repository, and set Git tags to version it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In this case, you can achieve this by using branches and tags triggers.
Here's an example of Pipelines YAML configuration:
pipelines: tags: 'release-*': # This will trigger by pushing a tag with the name pattern release-* - step: name: Release by tag script: #- Do validation here for the variable $BITBUCKET_BRANCH and create a repository variable for the default branch (e.g. $DEFAULT_BRANCH) // You can use bash if else here then return exit 1 if it's not the same. - echo "Some commands here to release" branches: default_branch: # This will trigger for the default branch - step: name: Release by branch script: - echo "Some commands here to release"
The above YAML configuration works when there's a new commit push to the default_branch branch and when there's a new tag push.
For the tags trigger, you can do the validation first before proceeding to run your release commands.
Hope it helps and let me know if you have any further questions.
Regards,
Mark C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.