I’m trying to run a shell script file inside a docker container. It’s working as expected when testing it with the command line but not when running it inside Jenkins (Windows Buildserver).
This is my Dockerfile:
FROM ubuntu:latest RUN apt-get update \ && apt-get dist-upgrade -y \ && apt-get install -y \ build-essential libgtest-dev \ && apt-get clean WORKDIR /src COPY . . #working when using CLI and Jenkinsfile RUN echo "test" #working when using CLI and Jenkinsfile RUN ls #working when using CLI but NOT with Jenkinsfile RUN ./build.sh CMD ["./run_tests.sh"]
And this is how I run the dockerfile:
#!/bin/sh set -x #stop and rm old container if any docker container stop build-fw docker container rm build-fw docker build -t build-fw . docker run --name build-fw -d -it build-fw docker logs build-fw docker container stop build-fw docker container rm build-fw
In Jenkins, I simply created a Freestyle project with the “Execute Shell” build step, where I simply ran the “docker-build.sh” script:
I got the following error output:
#12 0.586 /bin/sh: 1: ./build.sh: not found #12 ERROR: executor failed running [/bin/sh -c ./build.sh]: exit code: 127 ------ > [8/8] RUN build.sh: ------ executor failed running [/bin/sh -c ./build.sh]: exit code: 127
The error in Jenkins states, that
./build.sh was not found, although
RUN ls shows that
However this works as expected when using CLI.
How can I fix this issue ?