我是 CI 系统设置的新手,所以请保持温柔 :)
我正在关注 Stark And Wayne tutorial & 尝试获取 Concourse CI 任务 yml 以运行它通过输入文件夹找到的 shell 脚本:
任务.yml
---
platform: linux
image_resource:
type: docker-image
source: {repository: busybox}
inputs:
- name: my-input-folder
run:
path: ./my-input-folder/my-shell-script.sh
所以当我运行时:
fly --target team-name execute --config task.yml -i my-input-folder=my-input-folder
它应该进入该文件夹,操作 my-shell-script.sh
并回显其中的 this is working
。
相反,我得到:
hijack: Backend error: Exit status: 500, message: {"Type":"","Message":"runc exec: exit status 1: exec failed: container_linux.go:264: starting container process caused \"exec: \\\"./__tests__/this-is-my-shell-script.sh\\\": permission denied\"\n","Handle":""}
我知道这与 docker/busybox 图像有关,from this other thread .
但是……
a) 为什么它在他们的教程中使用相同的 .sh
扩展名和 busybox
图像? (但是当我在我的实际项目中使用它时不是?)
b) 我如何解决这个问题以便我的项目运行 shell 脚本?哪个 docker 镜像可以工作?
最佳答案
我通过同事发现这个错误是由于:
a) 需要 chmod +x folder/name-of-file.sh
所以它是一个可执行文件。
和
b) 将 #!/bin/sh
添加到我的 .sh
文件的开头(因为我正在使用 oh-my-zsh)。虽然我知道如果我使用的是 bash,这将是 #!/bin/bash
。
现在 shell 脚本链接正常。
关于javascript - 为什么 .sh shell 脚本在 Concourse 教程中有效,但在我的实际代码库中却无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47634034/