git - Docker Webhook容器:应该运行脚本,但是脚本无法正确执行(仅回显有效)

标签 git bash docker sh webhooks

因此,我建立了一个基于almir/webhook的Docker容器,并在镜像中添加了git和docker,以便可以运行相应的命令。问题是,它在我手动测试时运行,甚至在我通过终端从容器内部启动脚本时运行。但是,当我通过URL触发脚本时,我只会得到回显,而不会执行任何“真实”命令。

我的脚本如下所示:

#!/bin/sh

echo "current directory: " + $PWD
git pull
echo "pulling from git"
docker exec -ti geda-drupal gedankenbruecke/vendor/drush/drush/drush st
echo "clear drupal cache"
echo "Script finished successful"
echo "testPull"

我的输出是这样的:
[webhook] 2017/10/03 21:08:58 incoming HTTP request from 172.18.0.4:38050
[webhook] 2017/10/03 21:08:58 tuleapPull got matched
[webhook] 2017/10/03 21:08:58 tuleapPull hook triggered successfully
[webhook] 2017/10/03 21:08:58 2017-10-03T21:08:58Z | 200 |   61.3µs | webhook.localhost | GET /hooks/tuleapPull 
[webhook] 2017/10/03 21:08:58 executing /var/webhook/scripts/tuleapPull.sh (/var/webhook/scripts/tuleapPull.sh) with arguments ["/var/webhook/scripts/tuleapPull.sh"] and environment [] using /var/repo/ as cwd
[webhook] 2017/10/03 21:08:58 command output: current directory:  + /var/repo
pulling from git
clear drupal cache
Script finished successful
testPull

[webhook] 2017/10/03 21:08:58 finished handling tuleapPull

因此,脚本似乎已正确执行,但重要的命令却未正确执行。我通过对存储库进行新的推送来测试它,这会触发webhook-Url,然后它应该让容器从存储库中拉出,但这不会发生。只有当我手动启动脚本时,脚本才能正确执行。

有没有人提示问题可能出在哪里?

最佳答案

Only when I start the script manually, the script gets executed correctly.



一种可能的原因是两种情况下使用的环境变量和用户帐户不同。
尝试在脚本中显示它们(使用envid -a),以查看两种执行模式之间的区别(手动或通过Webhook)

关于git - Docker Webhook容器:应该运行脚本,但是脚本无法正确执行(仅回显有效),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46554478/

相关文章:

github 和 Composer 。 pull 存储库分支

git - 如何使用 Git 清理行尾

linux - 通过 ssh 从最新更改的目录中获取 Tar 文件

bash - 使用 sed 将 1234.0 更改为 1234 但保留 1.0234

docker - Dockerfile共享相同的指令,但是从不同的镜像构建

git - git merge 的 rebase 选项的目的是什么?

git - 如何撤消 git rm

Bash重命名扩展递归

Docker 和 asp.net core 使用 "scratch"图像最小化分布?

amazon-web-services - 如何配置在 AWS/ElasticBeanstalk/Docker 上运行的 GlassFish 实例?