Issue Summary
This is reproducible on Data Center:
This is likely a combined bug with:
Bamboo will delete the whole Docker runner container contents, INCLUDING LONG-TERM, MOUNTED VOLUMES data in the Docker host, if the ${bamboo.build.working.directory} location can't be accessed and the "Clean working directory after each build" is enabled under the Job's Other options
When the "Clean working directory after each build" option is enabled, Bamboo will call com.atlassian.bamboo.utils#QuietlyRemoved which will invoke the creation of the cleanDirectory.sh script to be executed on the container. As Bamboo could not initially cwd to the ${bamboo.build.working.directory} directory as it didn't exist, the script would be executed on the container's root folder ( / ) with the following content:
#!/bin/sh find . -mindepth 1 -delete >/dev/null 2>&1
That find command invocation will delete all the files in the container, including files that are long-term set as mounted external volumes on the Job's Docker configuration >> Volumes properties.
Steps to Reproduce
- Configure a Job with Docker Runner and enable "Clean working directory after each build" under Other options
- Have the ${bamboo.build.working.directory} not created, to get there you can assign a different volume to the ${bamboo.build.working.directory} location on the Job's configuration "Volume" properties. E.g.:
${bamboo.build.working.directory} >> /opt/src
- Have an extra path to the container configuration's volume setting that would be mounted as an external, long-term volume. E.g.
/home/ccache >> /home/ccache
- Populate the /home/ccache folder with data you expect to remain after the build
- Add a simple "hello world" task to the Plan
- Run the Plan
Expected Results
- The build should fail as Bamboo could not access the workdir
- The long-term data on the external volume should remain intact
Actual Results
- The build succeeds (green)
- No logs are available as they got removed before being transferred to the server
- All the data on the long-term volume is gone
Workaround
- Use only the default Job's ${bamboo.working.directory} mount point on the Job's Volume options
- Do not enable the "Clean working directory after each build" Job option. If the cleanup is necessary after each build, add a Final task (so it can run regardless of other Task results) to the Job and invoke a Script Task that would remove the desired content from the folders you wish in a controlled way.
Form Name |
---|