how to Change the build working directory on Bamboo Stock Image elastic agents
Asked by Mohammed.Ammar:

Hi,

how to Change the build working directory on Bamboo Elastic agent ?

I used the below

i want to change from this to C:\\Users\\bamboo_agent\\bamboo-agent-home\\xml-data\\build-dir\\ to C:\\Users\\bamboo_agent

```
icacls "C:\Users\bamboo_agent" /grant Bamboo:(OI)(CI)F /T
sed -i "s/<buildWorkingDirectory>.*</<buildWorkingDirectory>c:\\\Users\bamboo_agent</" C:\Users\bamboo_agent\bamboo-agent-home\bamboo-agent.cfg.template.xml
```

Please help and have a look, if anything i wrong or needs change

Thank you

I


Answers:
author: Eduardo Alvarenga
body: Hello [@Mohammed.Ammar](/t5/user/viewprofilepage/user-id/5157255)

Welcome to **Atlassian Community**!

You are correct. You have to modify the **bamboo-agent.cfg.template.xml** file to indicate another path for the build location.

Your sed command seems wrong. Try this:

```
sed -i 's@\(.*\<buildWorkingDirectory>\)\(.*\)\(</buildWorkingDirectory>.*\)@\1C\:\\Users\\bamboo_agent\3@' bamboo-agent.cfg.template.xml
```

The sed above uses 3 capture groups and replaces the second one with the content you want. E.g.:

```
<buildWorkingDirectory>C:\Users\bamboo_agent</buildWorkingDirectory>
```

Cheers,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**

comments: author: Mohammed.Ammar
body: Hi [@Eduardo Alvarenga](/t5/user/viewprofilepage/user-id/4365410)

```
sed -i 's@\(.*\<buildWorkingDirectory>\)\(.*\)\(</buildWorkingDirectory>.*\)@\1C\:\\Users\\bamboo_agent\3@' bamboo-agent.cfg.template.xml
```

This not worked, FYI.. we have added this script in Bamboo server, go to **Admin \>\> Elastic Instances \>\> Image Configurations \>\> Instance startup script field**

Do we need to change/add anything on Elastic Instance level, I mean add anything on **bamboo-agent.cfg.template.xml File ?**

Please let us know, if i am doing anything any wrong ?  
Thank you


author: Eduardo Alvarenga
body: Hello [@Mohammed.Ammar](/t5/user/viewprofilepage/user-id/5157255)

When you mentioned customisation, I assumed you were making changes to the Image that was going to be used as a new AMI.

As you are going to use the *Instance Startup Script* you need to add the whole path to the XML file as an argument and protect some backslashes as it will make use of GNU "sed" which is part of Cygwin. Make sure to understand the full extension of the command before adding it to the instance.

This should work as an Instance Startup Script:

```
mkdir C:\Users\bamboo_agent
icacls "C:\Users\bamboo_agent" /grant Bamboo:(OI)(CI)F /T
sed -i "s@\(.*\<buildWorkingDirectory>\)\(.*\)\(</buildWorkingDirectory>.*\)@\1C\:\\\\Users\\\\Bamboo_agent\3@" c:\Users\Bamboo\bamboo-agent-home\bamboo-agent.cfg.template.xml
```

Thanks!

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**


author: Mohammed.Ammar
body: Hi [@Eduardo Alvarenga](/t5/user/viewprofilepage/user-id/4365410)

Thank you for looking into it.

The script is still not working, There is something i have noticed..

In our setup we have only "**bamboo-agent.cfg.xml"**File present in Path: C:\\Users\\bamboo_agent\\bamboo-agent-home\\bamboo-agent.cfg.xml

But no **"bamboo-agent.cfg.template.xml"**File is present, Does both the files same or is it different ? or we missing any configuration ?

Thank You


author: Eduardo Alvarenga
body: Hello [@Mohammed.Ammar](/t5/user/viewprofilepage/user-id/5157255)

The provided answer assumes you are using the [stock images](https://confluence.atlassian.com/bamboo/stock-images-289277463.html) provided by Atlassian and that you are running a [supported version of Bamboo](https://confluence.atlassian.com/support/atlassian-support-end-of-life-policy-201851003.html). If you are running a [customised version](https://confluence.atlassian.com/bamboo/creating-a-custom-elastic-image-linux-296093037.html) of that image or even a totally different one -- based on the **C:\\Users\\Bamboo_agent** instead of the default **C:\\Users\\Bamboo** -- you will have to adapt the instructions to your environment.

Unfortunately, we don't support customised images as every customer has their own version and that would become impossible to maintain.

Best regards,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**