Reputation: 5756
I'm using the latest Jenkins image (2.60.3) and then I would like to update the jenkins.war
file that is in /usr/share/jenkins/jenkins.war
to get an image with the latest version of it (2.73.3). I'm trying to achieve that using the following dockerfile:
FROM jenkins:latest
COPY jenkins.war /usr/share/jenkins/
I have the jenkins.war file in the same folder than the dockerfile. The issue I'm having is that for some reason the file doesn't get overwritten (there is the jenkins.war v2.60.3). Why that could be happening?
Upvotes: 1
Views: 1193
Reputation: 1329682
As commented, using the jenkins/jenkins image, I have (with the latest 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
That does give me an installed Jenkins LTS image, with all the plugins I need.
Since I am behind a proxy, I had to configure it first:
$ 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!"
And I need to define an admin account:
$ 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"
Finally, I don't want any job execution on the master:
$ more master-executors.groovy
import hudson.model.*;
import jenkins.model.*;
println "--> disabling master executors"
Jenkins.instance.setNumExecutors(0)
Upvotes: 2