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 .
@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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.