Missed Team ’24? Catch up on announcements here.

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

Select which scripts will run in the pipeline

Júlio César Fonseca Costa
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!
November 28, 2022

Hello,

I would like to know if it is possible when running a pipeline, to choose which scripts will be executed. Ex:

release: &release
- step:
     name:  Release
     trigger: manual
          deployment: production
          artifacts:
               download: false
           script:
               - chmod +x sh/script.sh
               - ./sh/script.sh api1
               - ./sh/script.sh api2
               - ./sh/script.sh api3
would it be possible to open a question asking which api for example I want to include to run the script?

In the way I developed the 3 always run, but I would like to have the possibility of being something dynamic, where sometimes I can run all or just one or two.

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 30, 2022

Hi @Júlio César Fonseca Costa and welcome to the community!

It is not possible to execute only some commands of a step's script. When a step runs, all the commands in its script will be executed sequentially (unless one of them fails and the step fails, then the rest won't be executed).

If you don't want all of them to be executed, you can create a separate manual step for each API and then run manually the step(s) you want.

Another option would be to use a custom pipeline that can make use of variables, as follows:

pipelines:
custom:
my-custom-pipeline-name: #name of this pipeline
- variables: #list variable names under here
- name: api
default: "api1" # optionally provide a default variable value
allowed-values: # optionally restrict variable values
- "api1"
- "api2"
- "api3"
- step:
script:
- chmod +x sh/script.sh
- ./sh/script.sh $api

In this example, I am using a variable named api, with allowed values api1, api2, and api3. When you try to run manually a custom pipeline like this, you will be asked to choose the value for the variable api. If you want to run more than 1 apis, you will need to run the custom pipeline multiple times, one for each value.

If you have any questions, please feel free to let me know.

Kind regards,
Theodora

Júlio César Fonseca Costa
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!
November 30, 2022

Hello @Theodora Boudale

Thanks for your answer, I'm going to use the option of having custom pipelines anyway.

Thank you very much.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 30, 2022

You are very welcome @Júlio César Fonseca Costa, please feel free to reach out if you ever need anything else!

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events