Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,911
Community Members
 
Community Events
176
Community Groups

Bitbucket pipelines - Condition: Run or skip step based on build output

We have a monorepo that contains about 5 projects. All these projects are build based on the git change history, so if project A is not changed, it is not build. This is al managed by Nx monorepo.

e want to split every deploy into its own step so that we have more control over each project's deployment.

In order to achieve this we need to change our build step so that it only executes if the dist folder contains the portal it is ment to deploy. I've read about the condition configuration, but i cannot find anything about checking build artifacts in a condition instead of the git commit that triggerd the change. So is there a way to skip (or directly pass) a step if the portal is not in the build artifact?

Build step

- step: &build
name: Build
caches:
- node
script:
- git fetch origin master:refs/remotes/master
- npm run build
artifacts:
- dist/**

Example Dist artifact

.
├── dist/
│ ├── login-portal
│ ├── Portal-Y


Our deploy step

- step: &deployLoginPortal
image: amazon/aws-cli:2.4.17
deployment: test
trigger: manual
script:
- aws s3 sync $LOGIN_OUTPUT_PATH s3://$LOGIN_S3_BUCKET/ --acl public-read # Sync the portal
# $LOGIN_OUTPUT_PATH = 'dist/login-portal'

Example condition (does not work)

condition:
changesets:
includePaths:
- $LOGIN_OUTPUT_PATH/** # only run if dist contains changes in $LOGIN_BUILD_PATH

How can I check the build artifact if a specific path exists so that I can execute or skip the build step?

2 answers

as theres no out of the box solution from atlassian, what i did was something like:

- step:
     script:
- |
if something exists; then
        echo true > condition.txt
fi
     artifacts:
- condition.txt
- step:
script:
- |
if $(cat condition.txt); then
exit 0
fi
- do stuff
i know this is bullshit as it still has to go through `build setup` on each step which check for this condition, which takes time... but its still better than nothing
0 votes
Norbert C Atlassian Team Feb 15, 2022

Hi @Robin van Tienhoven 

Thank you for contacting Atlassian Community, my name is Norbert and I'm a Bitbucket Cloud Support Engineer, it's nice to meet with you! Welcome to the Atlassian Community.

I would like to inform you that the functionality what you're looking for is unfortunately not available. The conditionsets configuration ONLY checks the content of the commit. 

For example if you commit a change to your repository and the change is located in the "includePaths" location, a build will be triggered, but unfortunately we yet to have the feature which checks for artifacts.

Best Regards,
Norbert
Atlassian Bitbucket Cloud Support

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events