Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-22118

Bamboo Docker Runner Job will not substitute ${bamboo.working.directory} variable if that is customised as a mount volume option

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Medium
    • None
    • 8.2.7, 9.2.1
    • Docker, Docker Runner
    • None

    Description

      Issue Summary

      This is reproducible on Data Center:

      A Bamboo Docker Runner Job will not modify its working directory variable to follow a customised workdir volume mount point. This will create a series of issues as the standard /home/bamboo/bamboo-agent-home/xml-data/build-dir/PLAN-KEY-JOB folder will not be created and Bamboo will still try to use it within the container and the build will fail.

      Steps to Reproduce

      1. Create a Plan with a Job running on Docker Runner
      2. Modify the Job's volume options:
        • From:
          ${bamboo.working.directory} >> ${bamboo.working.directory}
          
        • To (example):
          ${bamboo.working.directory} >> /opt/src
          
      3. Add a Checkout task to the Plan
      4. Run the build

      Expected Results

      1. The docker container mounts /opt/src
      2. Bamboo should use /opt/src as its ${bamboo.working.directory}
      3. The build should succeed 

      Actual Results

      1. Bamboo keeps the ${bamboo.working.directory} unchanged: 
        command	13-Mar-2023 10:24:14	Substituting variable: ${bamboo.working.directory} with /home/bamboo/bamboo-agent-home/xml-data/build-dir/PLAN-KEY-JOB
      2. As Bamboo relies on the docker volume mount option to create any directories inside the container, the customised directory /opt/src is created inside the container but the Bamboo Agent application will still consider the default folder location /home/bamboo/bamboo-agent-home/xml-data/build-dir/PLAN-KEY-JOB as its workdir instead of the customised volume. The build fails with Git not being able to access the workdir as it doesn't exist. That is also valid for any program that needs files in the workdir location.

      Workaround

      1. Use only the default Job's ${bamboo.working.directory} mount point on the Job's Volume options
      2. As the first task of the Job, add a Script task that would create a symbolic link from Bamboo's workdir to the desired location:
        $ ln -sf ${bamboo_working_directory} /opt/src
      3. Build the Plan normally, and make sure to cwd to the desired location before issuing any commands that depend on a hardcoded path

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              73868399605e Eduardo Alvarenga
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: