Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to drigger different task for different changed files?

Andrey Tsarenko
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 5, 2018

For example.

My repo contains a three folders: "project1" "project2" and "core".

When I change a files under "core" folder I want trigger "npm run test Project1" and "npm run test project2".

If I changed the "project1" files I want test only "project 1".
If I changed the "poject2" - I want test only "project2".

I don't want to separate this folders on separate repositories, or use git submodules and subthrees. And also I don't want to every time test everything.

I heard that in teamcity such task is called triggers.

Does the "bitbucket pipeline" support this a kind of feature?

1 answer

0 votes
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 13, 2018

Hi Andrey,

I can't think of an easy way to achieve exactly what you're after in Pipelines. However have you considered running the tests for each project in separate parallel steps?

https://confluence.atlassian.com/bitbucket/parallel-steps-946606807.html

This would allow your pipeline to complete faster than running all the tests in a single step.

Obviously there are also disadvantages to this approach (primarily that you will use more build minutes relative to running just one set of tests at a time).

Otherwise it may be possible to write a custom script to do what you want using git commands, depending on your workflow. For instance if your workflow involves always squashing your commits into a single commit before pushing then you could use git commands to work out which projects are affected by the last commit. For instance the following commands output the number 1 if the corresponding project is affected by the last commit and 0 otherwise:

git diff-tree --no-commit-id --name-only HEAD core | wc -l
git diff-tree --no-commit-id --name-only HEAD project1 | wc -l
git diff-tree --no-commit-id --name-only HEAD project2 | wc -l

Cheers,
Steven

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events