dockerjenkinsdockerfilejenkins-job-builder

Can't add jenkins-job-builder in jenkins docker image


I'm new in docker. I want to create a docker container with Newman, Jenkins, Jenkins-job-builder. Please help me.

I built a docker image which bases on official Jenkins image https://hub.docker.com/r/jenkins/jenkins.

I used DockerFile. The build was successful, Jenkins app also runs successfully.

After running Jenkins I opened container as root docker exec -u 0 -it jenkins bash and tryed to add new job with jenkins-job-builder

jenkins-jobs --conf ./jenkins_jobs.ini update ./jobs.yaml

but I got bash: jenkins-jobs: command not found

There is my Dockerfile

FROM jenkins/jenkins
USER root
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash
RUN apt-get -y install nodejs
RUN npm install -g newman
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
RUN python get-pip.py
RUN pip install --user jenkins-job-builder
USER jenkins

Solution

  • When building your image, you get some warnings. Especially this one is interesting:

    WARNING: The script jenkins-jobs is installed in '/root/.local/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
    

    Simply remove the --user flag from RUN pip install --user jenkins-job-builder and you're fine.