Jenkins docker agent in declarative pipeline: file not found

匆匆过客 提交于 2019-12-03 02:52:55

You can run a shell command that is something like sh "docker 'node'"

What I've done is used a Jenkinsfile and Dockerfile (since I edit my images) and have the Jenkinsfile call a script that has

docker build --tag=image-name .
docker run --rm --name=image-name-container image-name \
./someScript.sh \
-j ${SCRIPT_PARAM1} \
-u ${SCRIPT_PARAM2} > ${DOCKER_OUTPUT_FILE_NAME}

inside of it.

Adding ~/.zshenv for zshell (or other file) to put docker in the path. I did this and problem resolved:

$ cat ~/.zshenv
export PATH=/usr/local/bin:$PATH

It looks like the docker inspect not run in the same env as docker pull.

On my Mac, the docker pull failed, then I configured node/agent to add such Name: PATH, Value: /usr/local/bin:$PATH to the Environment variables, then the docker pull will run normally. And docker inspect failed.

Then I add ~/.zshenv as above (and restart node/agent), the docker inspect worked finally.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!