How to send bamboo variables from Bamboo script to

2019-07-22 09:43发布

问题:

I'm using Docker plugin for bamboo and I need to execute a script in the docker container.

The sh script contains:

echo \"ini_source_path\": \"${bamboo.ini_source_path}\",

and if I put this line directly in Container Command, the ${bamboo.ini_source_path} will be replaced with value of this variable.

The problem in when I put /bin/bashscript.sh in Container Command because I'm getting a error:

script.sh: line 35: \"${bamboo.ini_source_path}\",: bad substitution

Is there a way I can reach bamboo.ini_source_path variable from my script in docker container?

Thanks!

回答1:

What version of Bamboo are you using? This problem was fixed in Bamboo 6.1.0:

Unable to use variables in Container name field in Run docker task

Workaround:

  • Create a Script Task that runs before the Docker Task.
  • Run commands like

    echo "export sourcepath=$ini_source_path" > scriptname.sh
    chmod +x scriptname.sh
    

The Docker Task will be map the ${bamboo.working.directory} to the Docker \data volume.

So the just created scriptname.sh script is available in the Docker container.The script will be executed, and will set the variable correctly.