SO i have the pipeline below, Which run fine when i commit to master but i want it to run a separate pipeline after master is tagged.
Which it does not... no erros or anything, I have read that this might not be possible? any advice on doing this?
image: node:18 clone: depth: full definitions: steps: - step: &tag-repo name: Tag with latest version number script: - npm version patch -m "[skip ci] bumped the version" - VERSION=$(node -e "console.log(require('./package.json').version);") - git push origin master # Push the changes to the master branch - git push origin --tags - cat package.json - step: &get-version name: Determine latest build number script: - VERSION=$(node -e "console.log(require('./package.json').version);") - ls -ltr - cat package.json pipelines: branches: master: - step: *tag-repo tags: "*": - step: *get-version
Hi @simon,
Does the following command from your bitbucket-pipelines.yml file add a commit and then a tag to this commit?
- npm version patch -m "[skip ci] bumped the version"
And do you expect the tags pipeline to run for this tag you added and pushed during the &tag-repo step?
If so, I believe the reason that the tags pipeline is not triggered is because of the [skip ci] text in the commit message. This will make pipelines skip any automated builds on this commit (including the tags pipeline).
I wouldn't recommend removing the [skip ci] text from the commit message, otherwise the master branch pipeline will get triggered as well when you push this commit, and then you'll have an endless loop of builds on master branch. There is, however, another way to trigger the tags pipeline.
You can use the pipe trigger-pipeline in your &tag-repo step, and this can trigger the tags pipeline despite the [skip ci] text.
If we assume that the variable VERSION is the one that has as value the name of the tag you just added, you can adjust the step as follows:
- step: &tag-repo
name: Tag with latest version number
script:
- npm version patch -m "[skip ci] bumped the version"
- VERSION=$(node -e "console.log(require('./package.json').version);")
- git push origin master # Push the changes to the master branch
- git push origin --tags
- cat package.json
- pipe: atlassian/trigger-pipeline:5.8.1
variables:
BITBUCKET_ACCESS_TOKEN: $BITBUCKET_ACCESS_TOKEN
REPOSITORY: '$BITBUCKET_REPO_SLUG'
REF_TYPE: 'tag'
REF_NAME: '$VERSION'
If the variable VERSION (that you define in the second line of the script) doesn't have as value the name of the tag you added, you can look into retrieving the tag name during the step and storing it in another variable that you can use in the pipe.
The variable BITBUCKET_REPO_SLUG is a default variable in Pipelines (no need to create it) and it has as value the repo slug of the repo where the build is currently running.
You will need to create the variable BITBUCKET_ACCESS_TOKEN.
Please feel free to let me know if this works for you and if you have any questions!
Kind regards,
Theodora
You're very welcome, Simon.
No, I'm afraid that there is no available access token that can be used for the pipe. It is necessary to create a new one.
It is also possible to use username and app password for authentication (this is mentioned in the pipe's README), however I recommended the access token for a more scoped approach (the username and app password would grant access to all repos an account has access to).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I i already have a bot and appsecret for that bot can i use that as the auth for the pipeline trigger. ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @simon,
Is that bot a separate Bitbucket account? If so, you could use its username and app password (ensure the app password has Pipelines Write and Repositories Read permissions), but the account also needs to have write permission to the repo in order to trigger a pipelines build with its credentials.
Kind regards,
Theodora
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.