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 ]

            Hello 5703fe6a1324,

            Thank you for the comment.

            Though you found a workaround for your issue, this reported issue is broader and will happen when using non-Script tasks such as a Checkout Task, which relies on the ${bamboo_working_directory} location as its starting point.

            Eduardo Alvarenga (Inactive) added a comment - - edited Hello 5703fe6a1324 , Thank you for the comment. Though you found a workaround for your issue, this reported issue is broader and will happen when using non-Script tasks such as a Checkout Task, which relies on the ${bamboo_working_directory} location as its starting point.

            This is created out of my question here: https://community.atlassian.com/t5/Bamboo-questions/Why-Job-gt-other-gt-quot-Clean-working-directory-after-each/qaq-p/2296264

            and is not the real issue.

            The workaround we are using is that I just do

            cd /opt/src

            at the beginning of my script.

            Nothing fails, everything works as it should (+ ignorable error in the log)

            Mariusz Dullak added a comment - This is created out of my question here: https://community.atlassian.com/t5/Bamboo-questions/Why-Job-gt-other-gt-quot-Clean-working-directory-after-each/qaq-p/2296264 and is not the real issue. The workaround we are using is that I just do cd /opt/src at the beginning of my script. Nothing fails, everything works as it should (+ ignorable error in the log)

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

                Created:
                Updated: