使用预先配置的作业创建Jenkins Docker Image [英] Create Jenkins Docker Image with pre configured jobs
问题描述
现在我想做的是让我们的所有开发人员都可以使用它,因此他们只需简单地旋转一个本地的jenkins实例即可已经包含工作。
我的码头文件是相当简单的...
FROM jenkins:最新
USER root
运行apt-get update
运行apt-get install -y sudo
RUN echojenkins ALL = NOPASSWD:ALL>> / etc / sudoers
#Docker
运行apt-get update
运行apt-get dist-upgrade -y
运行apt-get install apt-transport-https ca-certificates -y
RUN sh -cecho 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
运行apt-get update
运行apt-cache policy docker -engine
运行apt-get install docker-engine -y
#.NET Core CLI依赖项
RUN echodeb [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-recommendations \
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
运行ln -s / opt / dotnet / dotnet / usr / local / bin
#最小Jenkins插件
RUN /usr/local/bin/install-plugins.sh git matrix-auth workflow-aggregator docker-workflow blueocean credentials-binding
#跳过初始设置
ENV JAVA_OPTS -Djenkins.install.runSetupWizard = false
COPY LocallyDeployIdentityConfig.xml /var/jenkins_home/jobs/identity/config.xml
USER jenkins
我以为我可以做的只是将作业配置文件复制到/ jobs / jobname文件夹中,该作业将会出现,但不仅不会出现,现在我也无法手动创建作业。我现在得到一个java.io.IOException没有这样的文件或目录 - 注意当我执行到运行容器,作业和作业名称目录存在,我的配置文件在那里。
任何想法?
对于任何有兴趣的人,我找到了更好的解决方案。我简单地将作业文件夹映射到主机上的文件夹,这样我可以将创建的作业放入源代码控制和编辑,然后添加它们,而无需构建新的码头图像。
排序。
I have created a bunch of Local deployment pipeline jobs, these jobs do things like remove an existing container, build a service locally, build a docker image, run the container - etc. These are not CI/CD jobs, just small pipelines for deploying locally during dev.
What I want to do now is make this available to all our devs, so they can just simply spin up a local instance of jenkins that already contains the jobs.
My docker file is reasonably straight forward...
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 is simply copy a job config file into the /jobs/jobname folder and the job would appear, but not only does this not appear, but now I cannot manually create jobs either. I now get a java.io.IOException "No such file or directory" - Note when I exec into the running container, the job and jobname directories exist and my config file is in there.
Any ideas?
For anyone who is interested - I found a better solution. I simply map the jobs folder to a folder on my host, that way I can put the created jobs into source control and edit then add them without having to build a new docker image.
Sorted.
这篇关于使用预先配置的作业创建Jenkins Docker Image的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!