Forums

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

Can I Change repository environment variable value from shell script?

Mustafa Abdelhakam February 9, 2023

I know that I can set repository environment variable from repository setting,
but I need to change it's value inside my script and use it's new value some where else.

Is that possible?

my goal is sharing text message that is generated in build_script.sh to slack-notify message.


image: atlassian/default-image:4
pipelines:
custom:
new_publish:

- step:
name: new publish
script:
- echo "This step runs once you click the 'Run' button"
- /bin/sh build_script.sh

- pipe: atlassian/slack-notify:2.0.0
variables:
WEBHOOK_URL: $WEBHOOK_URL
MESSAGE: '"$MESSAGE that is generated in build_script.sh "'

 

 

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.
February 13, 2023

Hi @Mustafa Abdelhakam and welcome to the community!

Yes, this is possible. If you use a command like

- myVar="some text"

where myVar is a Repository variable, then the changed value will be used in the following commands of the same step. Please note that this will change the value of the variable for that specific step only, not for any other steps, and it won't change the value set in the Repository settings.

If you want to change the value of a variable in the Repository settings you can use the following API endpoint:

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

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events