如何将Bamboo变量从Bamboo脚本发送到Docker容器

如何将Bamboo变量从Bamboo脚本发送到Docker容器

本文介绍了如何将Bamboo变量从Bamboo脚本发送到Docker容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用适用于Bamboo的Docker插件,我需要在Docker容器中执行一个脚本.

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

sh脚本包含:

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

,如果我将这一行直接放在Container Command中,则$ {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.

由于出现错误,我将/bin/bashscript.sh放到Container Command中的问题:

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

有没有办法可以从Docker容器中的脚本中访问Bamboo.ini_source_path变量?

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

谢谢!

推荐答案

您正在使用哪个版本的Bamboo?在Bamboo 6.1.0中解决了此问题:

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

解决方法:

  • 创建一个在Docker Task之前运行的脚本任务.
  • 运行类似命令

  • 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

Docker任务将$ {bamboo.working.directory}映射到Docker \ data卷.

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

因此刚创建的scriptname.sh脚本在Docker容器中可用,该脚本将被执行并正确设置变量.

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

这篇关于如何将Bamboo变量从Bamboo脚本发送到Docker容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 18:57