用最新的jenkins创builddocker图像

我正在使用最新的Jenkins图像(2.60.3),然后我想更新/usr/share/jenkins/jenkins.warjenkins.war文件以获取最新版本的图像(2.73 0.3)。 我正在尝试使用下面的dockerfile来实现:

 FROM jenkins:latest COPY jenkins.war /usr/share/jenkins/ 

我有与dockerfile相同的文件夹中的jenkins.war文件。 我遇到的问题是由于某种原因文件不会被覆盖(有jenkins.war v2.60.3)。 为什么会这样呢?

正如所评论的,使用jenkins / jenkins图像 ,我有(使用最新的LTS ):

 FROM jenkins/jenkins:2.73.3 ARG http_proxy ARG https_proxy # Skip setup wizard ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false" USER root RUN addgroup --system --gid 581 dtpdkr && \ adduser jenkins dtpdkr USER jenkins # Remove executors in master COPY master-executors.groovy /usr/share/jenkins/ref/init.groovy.d/ # Set proxy based on proxy-password secret COPY set-proxy.groovy /usr/share/jenkins/ref/init.groovy.d/ # Create admin based on secrets jenkins-adm-name and jenkins-adm-pass COPY security.groovy /usr/share/jenkins/ref/init.groovy.d/security.groovy # Install plugins COPY plugins.txt /usr/share/jenkins/ref/plugins.txt RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt 

这确实给了我安装的jenkinsLTS图像,我需要的所有插件。

由于我在代理之后,我必须先configuration它:

 $ more set-proxy.groovy import hudson.model.*; import jenkins.model.*; def instance = Jenkins.getInstance() final String name = "proxy.mycompany.com" final int port = 8080 final String username = "unix_web_account" def password = new File("/run/secrets/proxy_password").text.trim() final String noProxyHost = "127.0.0.1,localhost,mycompany.com" final def pc = new hudson.ProxyConfiguration(name, port, username, password, noProxyHost) instance.proxy = pc instance.save() pc.save() println "Proxy settings updated!" 

我需要定义一个pipe理员帐户:

 $ more security.groovy #!groovy import jenkins.model.* import hudson.security.* import jenkins.security.s2m.AdminWhitelistRule def instance = Jenkins.getInstance() def user = new File("/run/secrets/jenkins-adm-name").text.trim() def pass = new File("/run/secrets/jenkins-adm-pass").text.trim() println "Creating user " + user + "..." def hudsonRealm = new HudsonPrivateSecurityRealm(false) hudsonRealm.createAccount(user, pass) instance.setSecurityRealm(hudsonRealm) def strategy = new FullControlOnceLoggedInAuthorizationStrategy() instance.setAuthorizationStrategy(strategy) instance.save() Jenkins.instance.getInjector().getInstance(AdminWhitelistRule.class).setMasterKillSwitch(false) println "User " + user + " was created" 

最后,我不希望主人执行任何工作。

 $ more master-executors.groovy import hudson.model.*; import jenkins.model.*; println "--> disabling master executors" Jenkins.instance.setNumExecutors(0)