Skip to content

Commit adb4209

Browse files
committed
JKNS-637: Remove deprecated references
- Remove CentOS references - Remove OpenShift V3 references - Use UBI base image for local development Dockerfile - Add all oc binaries for controller - Add latest stable oc binary for slave - Add groovy script to set node property and oc tools Signed-off-by: Vinu Kochukuttan <vkochuku@redhat.com> Signed-off-by: Vinu K <kevy.vinu@gmail.com>
1 parent 54ac219 commit adb4209

26 files changed

+154
-528
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
2/Dockerfile.localdev.version
2+
2/Dockerfile.rhel8.version
3+
2/Dockerfile.rhel9.version
24
agent-maven-3.5/Dockerfile.rhel7.version
35
agent-maven-3.5/Dockerfile.localdev.version
46
slave-base/Dockerfile.localdev.version
57
slave-base/Dockerfile.rhel7.version
68
slave-base/Dockerfile.rhel8.version
9+
slave-base/Dockerfile.rhel9.version
710
out
811
logs
912
kubeconfig

2/Dockerfile.localdev

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
##############################################
22
# Stage 1 : Build go-init
33
##############################################
4-
FROM openshift/origin-release:golang-1.12 AS go-init-builder
4+
FROM registry.access.redhat.com/ubi9/go-toolset:1.21 AS go-init-builder
55
ARG jenkins_version=latest
66
WORKDIR /go/src/github.com/openshift/jenkins
77
COPY . .
88
WORKDIR /go/src/github.com/openshift/jenkins/go-init
9-
RUN go build . && cp go-init /usr/bin
9+
RUN GO111MODULE=off go build -o /usr/bin/go-init .
1010

1111
##############################################
1212
# Stage 2 : Build slave-base with go-init
1313
##############################################
14-
FROM quay.io/openshift/origin-cli:4.16
14+
FROM registry.access.redhat.com/ubi9:latest
1515
ARG jenkins_version=latest
16-
MAINTAINER Akram Ben Aissi <abenaiss@redhat.com>
1716
COPY --from=go-init-builder /usr/bin/go-init /usr/bin/go-init
1817
# Jenkins image for OpenShift
1918
#
2019
# This image provides a Jenkins server, primarily intended for integration with
21-
# OpenShift v3.
20+
# OpenShift v4.
2221
#
2322
# Volumes:
2423
# * /var/jenkins_home
@@ -31,31 +30,35 @@ ENV JENKINS_VERSION=2 \
3130
HOME=/var/lib/jenkins \
3231
JENKINS_HOME=/var/lib/jenkins \
3332
JENKINS_UC=https://updates.jenkins.io \
34-
OPENSHIFT_JENKINS_IMAGE_VERSION=4.10 \
33+
OPENSHIFT_JENKINS_IMAGE_VERSION=4.17 \
3534
LANG=en_US.UTF-8 \
3635
LC_ALL=en_US.UTF-8 \
3736
INSTALL_JENKINS_VIA_RPMS=false
3837

39-
LABEL k8s.io.description="Jenkins is a continuous integration server" \
40-
k8s.io.display-name="Jenkins 2" \
41-
openshift.io.expose-services="8080:http" \
42-
openshift.io.tags="jenkins,jenkins2,ci" \
38+
LABEL io.k8s.description="Jenkins is a continuous integration server" \
39+
io.k8s.display-name="Jenkins 2" \
40+
maintainer="Prashant Dhamdhere <prdhamdh@redhat.com>, Vinu Kochukuttan <vkochuku@redhat.com>" \
41+
io.openshift.expose-services="8080:http" \
42+
io.openshift.tags="jenkins,jenkins2,ci" \
4343
io.jenkins.version="${jenkins_version}" \
44-
io.openshift.s2i.scripts-url=image:///usr/libexec/s2i
44+
io.openshift.s2i.scripts-url="image:///usr/libexec/s2i"
4545

4646
# 8080 for main web interface, 50000 for slave agents
4747
EXPOSE 8080 50000
4848

49-
RUN rm /etc/yum.repos.d/*
50-
COPY contrib/openshift/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
51-
RUN curl http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-Official -o /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS && \
52-
INSTALL_PKGS="dejavu-sans-fonts rsync gettext git git-lfs tar zip unzip openssl bzip2 java-21-openjdk java-21-openjdk-devel java-17-openjdk java-17-openjdk-devel jq xmlstarlet" && \
53-
DISABLES="" && \
54-
yum $DISABLES -y --setopt=tsflags=nodocs --disableplugin=subscription-manager install epel-release && \
55-
yum $DISABLES -y --setopt=tsflags=nodocs --disableplugin=subscription-manager install $INSTALL_PKGS && \
56-
yum update --excludepkgs redhat-release -y && \
49+
RUN INSTALL_PKGS="dejavu-sans-fonts wget rsync gettext git git-lfs tar zip unzip openssl bzip2 java-21-openjdk java-21-openjdk-devel java-17-openjdk java-17-openjdk-devel jq glibc-locale-source xmlstarlet glibc-langpack-en" && \
50+
yum install -y $INSTALL_PKGS && \
51+
yum update -y && \
5752
rpm -V $INSTALL_PKGS && \
5853
yum clean all && \
54+
mkdir -p /usr/share/openshift/bin/oc-41{2..7} && \
55+
curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.12/openshift-client-linux.tar.gz | tar zxf - -C /usr/share/openshift/bin/oc-412/ oc && \
56+
curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.13/openshift-client-linux.tar.gz | tar zxf - -C /usr/share/openshift/bin/oc-413/ oc && \
57+
curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.14/openshift-client-linux.tar.gz | tar zxf - -C /usr/share/openshift/bin/oc-414/ oc && \
58+
curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.15/openshift-client-linux.tar.gz | tar zxf - -C /usr/share/openshift/bin/oc-415/ oc && \
59+
curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.16/openshift-client-linux.tar.gz | tar zxf - -C /usr/share/openshift/bin/oc-416/ oc && \
60+
curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.17/openshift-client-linux.tar.gz | tar zxf - -C /usr/share/openshift/bin/oc-417/ oc && \
61+
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
5962
alternatives --set java $(alternatives --display java | grep 'family java-21-openjdk' | cut -d ' ' -f 1) && \
6063
alternatives --set javac $(alternatives --display javac | grep 'family java-21-openjdk' | cut -d ' ' -f 1) && \
6164
alternatives --family $(alternatives --display java | grep 'family java-21-openjdk' | cut -d ' ' -f 4) --install /usr/bin/jar jar $(alternatives --display java | grep 'family java-21-openjdk' | cut -d' ' -f1 | sed 's,/[^/]*$,/jar,') 1 && \
@@ -67,7 +70,7 @@ ADD ./contrib/s2i /usr/libexec/s2i
6770
ADD release.version /tmp/release.version
6871

6972
RUN /usr/local/bin/install-jenkins-core-plugins.sh /opt/openshift/bundle-plugins.txt && \
70-
rmdir /var/log/jenkins && \
73+
rm -rf /var/log/jenkins && \
7174
chmod -R 775 /etc/alternatives && \
7275
chmod -R 775 /var/lib/alternatives && \
7376
chmod -R 775 /usr/lib/jvm && \
@@ -81,6 +84,7 @@ RUN /usr/local/bin/install-jenkins-core-plugins.sh /opt/openshift/bundle-plugins
8184
/usr/local/bin/fix-permissions /var/lib/jenkins && \
8285
/usr/local/bin/fix-permissions /var/log
8386

87+
8488
VOLUME ["/var/lib/jenkins"]
8589

8690
USER 1001

2/cccp.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

2/contrib/jenkins/install-jenkins-core-plugins.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ if [[ "${INSTALL_JENKINS_VIA_RPMS}" == false ]]; then
1818
echo "jenkins.war already exists, skipping upstream RPM installation"
1919
else
2020
echo "Installing jenkins.war from upstream RPM"
21-
curl https://pkg.jenkins.io/redhat-stable/jenkins.repo -o /etc/yum.repos.art/ci/jenkins.repo
21+
mkdir -p /etc/yum.repos.art/ci
22+
curl https://pkg.jenkins.io/redhat-stable/jenkins.repo -o - | tee /etc/yum.repos.d/jenkins.repo /etc/yum.repos.art/ci/jenkins.repo
2223
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins-ci.org.key
2324
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
2425
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

2/contrib/jenkins/install-plugins.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# Usage:
77
#
8-
# FROM openshift/jenkins-2-centos7
8+
# FROM registry.redhat.io/ocp-tools-4/jenkins-rhel9:v4.17.0
99
# COPY plugins.txt /plugins.txt
1010
# RUN /usr/local/bin/install-plugins.sh /plugins.txt
1111
#

2/contrib/openshift/CentOS-Base.repo

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import jenkins.model.Jenkins
2+
import hudson.slaves.EnvironmentVariablesNodeProperty
3+
import hudson.slaves.EnvironmentVariablesNodeProperty.Entry
4+
import com.openshift.jenkins.plugins.OpenShiftClientTools
5+
import jenkins.model.Jenkins
6+
7+
println "Configuring node property ..."
8+
9+
def instance = Jenkins.instance
10+
11+
def nodeProps = instance.nodeProperties
12+
def envProp = nodeProps.get(EnvironmentVariablesNodeProperty)
13+
14+
if (envProp == null) {
15+
def newEnv = new EnvironmentVariablesNodeProperty(
16+
new Entry("PATH+OC", "/usr/share/openshift/bin/oc-417"),
17+
)
18+
nodeProps.add(newEnv)
19+
} else {
20+
def envVars = envProp.envVars
21+
22+
envVars.put("PATH+OC", "/usr/share/openshift/bin/oc-417")
23+
}
24+
25+
instance.save()
26+
27+
println "Environment variables updated."
28+
29+
println "Configuring oc tools ..."
30+
31+
def descriptor = Jenkins.instance.getDescriptor(OpenShiftClientTools)
32+
33+
def toolsToAdd = [
34+
"oc-412": "/usr/share/openshift/bin/oc-412",
35+
"oc-413": "/usr/share/openshift/bin/oc-413",
36+
"oc-414": "/usr/share/openshift/bin/oc-414",
37+
"oc-415": "/usr/share/openshift/bin/oc-415",
38+
"oc-416": "/usr/share/openshift/bin/oc-416",
39+
"oc-417": "/usr/share/openshift/bin/oc-417"
40+
]
41+
42+
def existing = descriptor.getInstallations() as List
43+
44+
toolsToAdd.each { name, path ->
45+
if (!existing.any { it.name == name }) {
46+
existing << new OpenShiftClientTools(name, path, [])
47+
println "Added: $name -> $path"
48+
} else {
49+
println "Skipped (already exists): $name"
50+
}
51+
}
52+
53+
descriptor.setInstallations(existing.toArray(new OpenShiftClientTools[0]))
54+
descriptor.save()
55+
56+
println "All done!"

2/test/jenkins_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var _ = BeforeSuite(func() {
3333

3434
imageName = os.Getenv("IMAGE_NAME")
3535
if imageName == "" {
36-
imageName = "openshift/jenkins-2-centos7-candidate"
36+
imageName = "openshift/jenkins-2-rhel9-candidate"
3737
}
3838
})
3939

ADVANCED_USAGE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A quick recipe of how to do that via layering would be:
1212
* create a Dockerfile with (adjusting the image ref as you see fit)
1313

1414
```
15-
FROM registry.access.redhat.com/ocp-tools-4/jenkins-rhel8:latest
15+
FROM registry.redhat.io/ocp-tools-4/jenkins-rhel9:v4.17.0
1616
COPY ./contrib/openshift /opt/openshift
1717
```
1818

@@ -23,13 +23,13 @@ the existing run script your new image inherits from this repositories Jenkins i
2323
Usage
2424
---------------------------------
2525

26-
For this, we will assume that you are using an `quay.io/openshift/origin-jenkins` for v4.x.
26+
For this, we will assume that you are using an `registry.redhat.io/ocp-tools-4/jenkins-rhel9` for v4.x.
2727

2828
If you want to set only the mandatory environment variables and store the database
2929
in the `/tmp/jenkins` directory on the host filesystem, execute the following command:
3030

3131
```
32-
$ docker run -d -e JENKINS_PASSWORD=<password> -v /tmp/jenkins:/var/lib/jenkins openshift/jenkins-2-centos7
32+
$ docker run -d -e JENKINS_PASSWORD=<password> -v /tmp/jenkins:/var/lib/jenkins ocp-tools-4/jenkins-rhel9:v4.17.0
3333
```
3434

3535

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The master images follow the normal numbering scheme in which the
22
# major version is used as the directory name and incorporated into
3-
# the image name (jenkins-2-centos7 in this case). For the slave
3+
# the image name (jenkins-2-rhel9 in this case). For the slave
44
# images we are not versioning them (they actually pull their
55
# jars from the jenkins master, so they don't have a jenkins version,
66
# so the only thing we'd version is the maven/nodejs version).
@@ -13,10 +13,12 @@ VERSIONS="2 slave-base"
1313
BUNDLE_PLUGINS="$(shell pwd)/2/contrib/openshift/bundle-plugins.txt"
1414
REF=$(shell mktemp -d)
1515
JENKINS_WAR="$(shell mktemp -d)/jenkins.war"
16-
ifeq ($(TARGET),rhel8)
16+
ifeq ($(TARGET),rhel9)
17+
OS := rhel9
18+
else ifeq ($(TARGET),rhel8)
1719
OS := rhel8
18-
else
19-
OS := centos8
20+
else
21+
OS := ubi
2022
endif
2123

2224
.PHONY: build

0 commit comments

Comments
 (0)