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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to run same step for a list of libraries in parallel

I am having bitbucket pipeline setup for an angular project. I have multiple libraries in the angular project and as part of pipelines I am running unit test for all of them in parallel. 

Right now I have the steps defined separately for each library like below:

 - step: &test-directory-data-access
name: Execute directory-data-access unit tests
size: 2x # Double resources available for this step.
max-time: 7
script:
- cd dbaasui
- npm test "directory-data-access"
artifacts:
- dbaasui/coverage/**
- step: &test-directory-ui-directory
name: Execute directory-ui-directory unit tests
size: 2x # Double resources available for this step.
max-time: 7
script:
- cd dbaasui
- npm test "directory-ui-directory"
artifacts:
- dbaasui/coverage/**

 

and running them in parallel as below:

 - parallel:
#steps for directory
- step: *test-directory-feature-shell
- step: *test-directory-data-access

 

I want to know if there is a way wherein I can define a single step definition which takes in library name as a dynamic variable and run those in parallel .

1 answer

0 votes

@Saurabh Kumar pipeline script can take variable, but only through manual running.

test: &test
step:
name: Your pipeline with variable
script:
- test $var
custom-pipeline:
- variables:
- name: var
- <<: *test

 

To do your tests automatically, you have to do it in separate steps:

test-lib1: &test-lib-1

  script:

    - test folder

 

test-lib2: &test-lib-2

....

Because the purpose of pipeline to be more declarative.

 

Or you can run test for folder by recongnizing how folder is called.

E.g. you have in work directory folder1 and folder2 and depending on what current directory is, you can run on it.

 

But it will be harder to debug in any case if you have some problems with  pipelines, we would still recommend to use more declarative way.

 

Regards, Galyna

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

110 views 1 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you