Create a Dener Jenkins Image with Predefined Jobs

I have created many tasks for the local deployment pipeline, these tasks do things such as deleting an existing container, creating a service locally, assembling a docker image, launching a container, etc. These are not CI / CD jobs, just small pipelines for deploying locally during development.

Now I want to make this available to all of our developers, so they can just simply deploy a local jenkins instance that already contains jobs.

My docker file is quite simple ...

FROM jenkins:latest USER root RUN apt-get update RUN apt-get install -y sudo RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers # Docker RUN apt-get update RUN apt-get dist-upgrade -y RUN apt-get install apt-transport-https ca-certificates -y RUN sh -c "echo deb https://apt.dockerproject.org/repo debian-jessie main > /etc/apt/sources.list.d/docker.list" RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D RUN apt-get update RUN apt-cache policy docker-engine RUN apt-get install docker-engine -y # .NET Core CLI dependencies RUN echo "deb [arch=amd64] http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.6 main" > /etc/apt/sources.list.d/llvm.list \ && wget -q -O - http://llvm.org/apt/llvm-snapshot.gpg.key|apt-key add - \ && apt-get update \ && apt-get install -y --no-install-recommends \ clang-3.5 \ libc6 \ libcurl3 \ libgcc1 \ libicu52 \ liblldb-3.6 \ liblttng-ust0 \ libssl1.0.0 \ libstdc++6 \ libtinfo5 \ libunwind8 \ libuuid1 \ zlib1g \ && rm -rf /var/lib/apt/lists/* #DotNetCore RUN curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?linkid=847105 RUN mkdir -p /opt/dotnet && tar zxf dotnet.tar.gz -C /opt/dotnet RUN ln -s /opt/dotnet/dotnet /usr/local/bin # Minimal Jenkins Plugins RUN /usr/local/bin/install-plugins.sh git matrix-auth workflow-aggregator docker-workflow blueocean credentials-binding # Skip initial setup ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false COPY LocallyDeployIdentityConfig.xml /var/jenkins_home/jobs/identity/config.xml USER jenkins 

What I thought I could do was just copy the job configuration file to the / jobs / jobname folder, and the job will appear, but it’s not only not displayed, but now I can’t manually create the jobs. Now I get java.io.IOException "There is no such file or directory" - Please note that when I execute the command in the running container, there are directories with the name job and jobname, and my configuration file is there.

Any ideas?

+5
source share
2 answers

For everyone who is interested, I have found the best solution. I just map the tasks folder to the folder on my host so I can put the created tasks into the original control and edit, and then add them without creating a new docker image.

Sorted.

+5
source

I save jobs in the bootstrap folder along with configurations, etc.

To add a job (i.e. seedjob), I need to add the following to the Dockerfile :

 # copy seedjob COPY bootstrap/seedjob.xml /usr/share/jenkins/ref/jobs/seedjob/config.xml 
0
source

Source: https://habr.com/ru/post/1267307/


All Articles