Docker在Docker Bamboo Task

时间:2017-12-21 06:53:39

标签: bash docker bamboo

我想使用以下命令运行docker openjdk:8-jdk:

if [ "$GIT_BRANCH" = "master" ]; then ./gradlew publish; else echo Skipped because it is not master branch; fi

我尝试执行以下操作:

docker run  --rm openjdk:8-jdk "if [ \"$GIT_BRANCH\" = \"master\" ]; then echo hi; else echo bla; fi"

但是我收到以下错误:$ PATH中找不到可执行文件“:unknown。

此外,我不可能使用if语句:

if ...
  docker run ...
else
  echo Skipped

因为我必须把它作为竹子码头工作来运行。

1 个答案:

答案 0 :(得分:0)

由于上面的命令没有在bash中执行,所以必须首先启动bash:

docker run  --rm openjdk:8-jdk /bin/bash -c "if [ \"$GIT_BRANCH\" = \"master\" ]; then ./gradlew publish; else echo Skipped because it is not master branch; fi"