0

I have a CI pipeline in Bitbucket which is used to build and test a shared Node.js library. If we create tag (eg. npm version patch -m "Upgrade to 0.1.2 for bug fix") the new version must be published to the npm repository.

Therefore I have the following pipeline configuration:

pipelines:
  default:
    - step: *build-test-sonarcloud
  tags:
    '*':
      - step: *build-test-sonarcloud
      - step: *build-deploy-npm

However, if I push all changes after 'npm version patch' two pipelines are started. I suppose that this is because the file 'package.json' is also committed and not only a tag.

My idea is that only the 'tags'-pipeline should be started in case of a commit of a tag (with or without any files). Is there a way to only trigger that pipeline and prevent the default pipeline to run?

Laurens
  • 325
  • 2
  • 12

1 Answers1

0

When you mention '*' after tags step, this means, the pipeline will be running twice every time. You need to mention tag name, something like below code

pipelines:
  default:
    - step: *build-test-sonarcloud
  tags:
    'yourCustomTagName':
      - step: *build-test-sonarcloud
      - step: *build-deploy-npm

Now whenever you push your code with yourCustomTagName, then both the steps will run in the pipeline, if not only one will run.

Nayan shah
  • 543
  • 3
  • 8
  • Unfortunately, this does not seems to work. I have changed `tags: '*'` to `tags: 'v*'` (because we name them v0.1.1, etc.). And still both pipelines are triggered. Due to the versioning (using `npm version patch`) a fixed tag name is not possible for us. – Laurens Mar 16 '20 at 13:38
  • Are you marking your tag properly? I mean pushing your code like this npm push --tagname https://confluence.atlassian.com/bitbucket/repository-tags-321860179.html#Repositorytags-CreateataginBitbucket – Nayan shah Mar 17 '20 at 14:46
  • The tag is automatically created by the `npm version` command (see https://docs.npmjs.com/cli/version). Maybe the problem is that this _also_ pushes a new version of `package.json` which is of course not a tag, but a part of a commit. – Laurens Mar 18 '20 at 16:25