prevent the bitbucket pipline from tirggering when bitbucket-pipelines.yml is updated
Asked by t1279k:

I am new to bitbuckt pipeline. To my node project I have added `bitbucket-pipelines.yml` in the pipeline I have a step to build and push container to ECR and another step to deploy.

Now each time I make a change to bitbucket-pipelines.yml it build and pushes a new image to ECR and deploys.

I do not what the piepline to trigger when I make changes to bitbucket-pipelines.yml. I only want the pipeline to trigger when I make changes to my application. Am I setting up the project wrong?

my project structure.

![bitbucket.png](https://community.atlassian.com/t5/image/serverpage/image-id/134542i6050019E773A6F86/image-size/large?v=v2&px=999 "bitbucket.png")


Answers:
author: Theodora Boudale
body: Hi [@t1279k](/t5/user/viewprofilepage/user-id/4306534) and welcome to the community!

I am quoting here from our documentation:
> If you don't want to run a pipeline on a commit that would normally trigger one, you can include \[skip ci\] or \[ci skip\] anywhere in your commit message of the HEAD commit. Any commits that include \[skip ci\] or \[ci skip\] in the message are ignored by Pipelines.

My suggestion would be the following: if you have locally commits that change your application, push those first, so a pipeline will get triggered.

Then, create a separate commit that changes the bitbucket-pipelines.yml only, include **\[skip ci\]** anywhere in the commit message of this commit, push it and the pipeline won't get triggered. You can also change the bitbucket-pipelines.yml file from Bitbucket website and include **\[skip ci\]** in the commit message so that no build will run.

If you push multiple commits that change ++both++ your application and the bitbucket-pipelines.yml, and **\[skip ci\]** is included in the commit message of the last commit, then no pipeline will run for any of the previous commits either. This is why I am suggesting changing the bitbucket-pipelines.yml only in one commit and push only that.

I hope this helps, if you have any other questions, please feel free to let me know.

Kind regards,  
Theodora

comments: author: t1279k
body: Thanks for the information. I had read this. I was hoping there might be a one time setting that would prevent pipeline file from being ignored. In the suggestion given I would have to educate whole team on this, also there is a chance some one might forget adding it to the comment.


author: Theodora Boudale
body: Hi [@t1279k](/t5/user/viewprofilepage/user-id/4306534) ,

Thank you for your reply and feedback, and I certainly understand what you're saying.

I looked a bit more into this, and even though we don't have such a setting, there is another way you could achieve what you want:

The keyword **condition** (along with the keywords **changesets** and **includePaths**) can be included in the bitbucket-pipelines.yml file (for each step), to specify that the step will run only if one of the modified files matches the expressions you specify.

An example from our documentation is as follows:

```
- step:
    name: step1
    script:
      - echo "failing paths"
      - exit 1
    condition:
      changesets:
        includePaths:
          # only xml files directly under path1 directory
          - "path1/*.xml"
          # any changes in deeply nested directories under path2
          - "path2/**"
```

You could use this to include all directories and files from your application, except from the yml file.

E.g., based on the structure of your project that you posted, the condition part of your yml file could look like this:

```
condition:
  changesets:
    includePaths:
      - "*.sh"
      - "*.js"
      - "*.json"
      - "*.md"
      - "node_modules/**"
      - "Dockerfile"
```

With a condition like this, a step will run only when you modify any of the files included in **includePaths** , but not when the bitbucket-pipelines.yml file is edited (since this is not included in the **includePaths**).

Please note that this will need to be added to ++each step++ of your yml file, if you don't want any of the steps to be executed when only the yml file is edited.

In case you later on add more files or directories in your application that don't match the patterns above, you'll need to add those in the **includePaths** as well.

I realize it may not be a very elegant solution compared to the ability to exclude files, but it's a workaround you may want to try.

You can read more details about this in our documentation (search for the **condition** keyword):

* <https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/>

Please also note that if you use this for all your steps, a build will still get triggered, but its steps **will not** be executed and its duration will show as 0, as follows:

![Screenshot 2021-03-22 at 13.36.51.png](https://community.atlassian.com/t5/image/serverpage/image-id/135355i799D72180CB09C3F/image-size/large?v=v2&px=999 "Screenshot 2021-03-22 at 13.36.51.png")

<br />

We do have a feature request to support an **excludePaths** option (similarly to includePaths), where you could specify files/directories whose changes would not trigger a build:

* <https://jira.atlassian.com/browse/BCLOUD-20700>

If you'd be interested in that, I would suggest that you add your vote in that feature request (by selecting the **Vote for this issue** link) as the number of votes helps the development team and product managers better understand the demand for new features. You are more than welcome to leave any feedback, and you can also add yourself as a watcher (by selecting the **Start watching this issue** link) if you'd like to get notified via email on updates.  

Please feel free to let me know if you have any questions.

Kind regards,  
Theodora


author: t1279k
body: -


Tags: bitbucket-cloud

bitbucket-pipelines

cloud