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-pipelines.yml
├── Dockerfile
├── index.js
├── node_modules
├── package.json
├── package-lock.json
└── README.md
There are a few possible options:
[skip ci]
to your git commit messageWhenever you change the bitbucket-pipelines.yml
on its own, add "[skip ci]" (without quotes) somewhere in your Git commit message. This will prevent the pipeline from running when you push to the Bitbucket remote.
Sources and more info:
Advantages:
Disadvantages:
"[skip ci]"
text. It's easy to forget, or perhaps a new team member will not know about it.Write a Git Hook script that will automatically insert the "[skip ci]" text into the Git commit message. The script will have to do something like this:
git diff --name-only HEAD~0 HEAD~1
bitbucket-pipelines.yml
was the only file changed, modify the commit to insert "[skip ci]"
into the commit message.More info about Git Hooks:
Advantages:
Disadvantages:
bitbucket-pipelines.yml
check for the file changesAdd a section in the yml
build script to check which file was changed in the latest commit.
The script in the yml will have to do something like this:
git diff --name-only HEAD~0 HEAD~1
bitbucket-pipelines.yml
was the only file changed, abort the CI build immediately, with an exit 0
statement.Advantages:
Disadvantages:
Define a changesets
with an includePaths
to execute a step only if one of the modified files matches the expression in includePaths
.
pipelines:
default:
- step:
name: build-frontend-artifact
condition:
changesets:
includePaths:
# only xml files directly under resources directory
- "src/main/resources/*.xml"
# any changes in frontend directory
- "src/site/**"
script:
- echo "Building frontend artifact"
Source and more info: