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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

How to have pipeline bash script edit a file?

Alright so I created a pipeline that calls a bash script whenever a commit is made to the master branch. In that bash script, I would like to open up a file in the branch that the commit was made to, update a number in it, then commit that new change. How can I go about doing that in a pipeline bash script? I'm not sure if I can have the bash script do a checkout or not. 

1 answer

0 votes
Mark C Atlassian Team Feb 13, 2022

Hi @Michael Pietrefesa,

Thank you for reaching out to the community.

You can definitely run Git commands in your bash script.
When it comes to changing your file on Pipelines, there's no option for you to open a file and edit it while the build is running.
You can, however, automate this process and we usually recommend using the "sed" command.
Sed Linux command will allow you to change a value in a file and save the final output using Git commands.

Here's an example of how to use the Sed command:

- apt-get install -y sed
- sed 's/dev/prod/g' production.env
- your_script_here.bash

(1) You'll need to install it on Pipelines first
(2) Here, I want to change the value "dev" to "prod" in the file production.env
(3) Do save the file changes using Git commands inside the bash script (e.g. Git add, commit, and push). Please also refer to this link for an example of how to push back to your repository.

Here are some relevant resources about Sed command as well:

Hope it helps and let me know how you go with the Sed command.

Mark C

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events