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

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

      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

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

            SET Analytics Bot made changes -
            UIS Original: 2 New: 0
            SET Analytics Bot made changes -
            UIS Original: 0 New: 2
            SET Analytics Bot made changes -
            UIS Original: 3 New: 0
            SET Analytics Bot made changes -
            UIS Original: 0 New: 3
            SET Analytics Bot made changes -
            UIS Original: 1 New: 0
            SET Analytics Bot made changes -
            UIS New: 1
            Jyothi Charupalli made changes -
            Remote Link New: This issue links to "Page (Confluence)" [ 741010 ]
            Krzysztof Podsiadło made changes -
            Status Original: Needs Triage [ 10030 ] New: Long Term Backlog [ 12073 ]
            Eduardo Alvarenga (Inactive) made changes -
            Description Original: h3. 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.
            h3. Steps to Reproduce
             # Create a Plan with a Job running on Docker Runner
             # Modify the Job's volume options:
             ** {*}From{*}:
            {noformat}
            ${bamboo.working.directory} >> ${bamboo.working.directory}
            {noformat}

             ** {*}To (example){*}:
            {noformat}
            ${bamboo.working.directory} >> /opt/src
            {noformat}

             # Add a Checkout task to the Plan
             # Run the build

            h3. Expected Results
             # The docker container mounts {{/opt/src}}
             # Bamboo should use {{/opt/src}} as its _${bamboo.working.directory}_
             # The build should succeed 

            h3. Actual Results
             # Bamboo keeps the _${bamboo.working.directory}_ unchanged: 
            {noformat}
            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{noformat}

             # 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.+

            h3. Workaround
             # Use only the default Job's _${bamboo.working.directory}_ mount point on the Job's Volume options
             # 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:
            {noformat}
            $ ln -sf ${bamboo_working_directory} /opt/src{noformat}

             # Build the Plan normally, and make sure to _cwd_ to the desired location before issuing any commands that depend on a hardcoded path
            New: h3. 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.
            h3. Steps to Reproduce
             # Create a Plan with a Job running on Docker Runner
             # Modify the Job's volume options:
             ** {*}From{*}:
            {noformat}
            ${bamboo.working.directory} >> ${bamboo.working.directory}
            {noformat}
             ** {*}To (example){*}:
            {noformat}
            ${bamboo.working.directory} >> /opt/src
            {noformat}
             # Add a Checkout task to the Plan
             # Run the build

            h3. Expected Results
             # The docker container mounts {{/opt/src}}
             # Bamboo should use {{/opt/src}} as its _${bamboo.working.directory}_
             # The build should succeed 

            h3. Actual Results
             # Bamboo keeps the _${bamboo.working.directory}_ unchanged: 
            {noformat}
            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{noformat}
             # 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.+

            h3. Workaround
             # Use only the default Job's _${bamboo.working.directory}_ mount point on the Job's Volume options
             # 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:
            {noformat}
            $ ln -sf ${bamboo_working_directory} /opt/src{noformat}
             # Build the Plan normally, and make sure to _cwd_ to the desired location before issuing any commands that depend on a hardcoded path
            Eduardo Alvarenga (Inactive) made changes -
            Description Original: h3. 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.
            h3. Steps to Reproduce
             # Create a Plan with a Job running on Docker Runner
             # Modify the Job's volume options:
             ** {*}From{*}:
            {noformat}
            ${bamboo.working.directory} >> ${bamboo.working.directory}
            {noformat}
             ** {*}To (example){*}:
            {noformat}
            ${bamboo.working.directory} >> /opt/src
            {noformat}
             # Add a Checkout task to the Plan
             # Run the build

            h3. Expected Results
             # The docker container mounts {{/opt/src}}
             # Bamboo should use {{/opt/src}} as its _${bamboo.working.directory}_
             # The build should succeed 

            h3. Actual Results
             # Bamboo keeps the _${bamboo.working.directory}_ unchanged: 
            {noformat}
            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{noformat}
             # 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.+

            h3. Workaround
             # Use only the default Job's _${bamboo.working.directory}_ mount point on the Job's Volume options
             # 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:
            {noformat}
            $ ln -s ${bamboo_working_directory} /opt/src{noformat}
             # Build the Plan normally, and make sure to _cwd_ to the desired location before issuing any commands that depend on a hardcoded path
            New: h3. 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.
            h3. Steps to Reproduce
             # Create a Plan with a Job running on Docker Runner
             # Modify the Job's volume options:
             ** {*}From{*}:
            {noformat}
            ${bamboo.working.directory} >> ${bamboo.working.directory}
            {noformat}

             ** {*}To (example){*}:
            {noformat}
            ${bamboo.working.directory} >> /opt/src
            {noformat}

             # Add a Checkout task to the Plan
             # Run the build

            h3. Expected Results
             # The docker container mounts {{/opt/src}}
             # Bamboo should use {{/opt/src}} as its _${bamboo.working.directory}_
             # The build should succeed 

            h3. Actual Results
             # Bamboo keeps the _${bamboo.working.directory}_ unchanged: 
            {noformat}
            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{noformat}

             # 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.+

            h3. Workaround
             # Use only the default Job's _${bamboo.working.directory}_ mount point on the Job's Volume options
             # 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:
            {noformat}
            $ ln -sf ${bamboo_working_directory} /opt/src{noformat}

             # Build the Plan normally, and make sure to _cwd_ to the desired location before issuing any commands that depend on a hardcoded path

              Unassigned Unassigned
              73868399605e Eduardo Alvarenga (Inactive)
              Affected customers:
              2 This affects my team
              Watchers:
              5 Start watching this issue

                Created:
                Updated: