Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
2/Dockerfile.localdev.version
2/Dockerfile.rhel8.version
2/Dockerfile.rhel9.version
agent-maven-3.5/Dockerfile.rhel7.version
agent-maven-3.5/Dockerfile.localdev.version
slave-base/Dockerfile.localdev.version
slave-base/Dockerfile.rhel7.version
slave-base/Dockerfile.rhel8.version
slave-base/Dockerfile.rhel9.version
out
logs
kubeconfig
Expand Down
44 changes: 24 additions & 20 deletions 2/Dockerfile.localdev
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
##############################################
# Stage 1 : Build go-init
##############################################
FROM openshift/origin-release:golang-1.12 AS go-init-builder
FROM registry.access.redhat.com/ubi9/go-toolset:1.21 AS go-init-builder
ARG jenkins_version=latest
WORKDIR /go/src/github.com/openshift/jenkins
COPY . .
WORKDIR /go/src/github.com/openshift/jenkins/go-init
RUN go build . && cp go-init /usr/bin
RUN GO111MODULE=off go build -o /usr/bin/go-init .

##############################################
# Stage 2 : Build slave-base with go-init
##############################################
FROM quay.io/openshift/origin-cli:4.16
FROM registry.access.redhat.com/ubi9:latest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use ose-cli-rhel9 image instead ubi ?

ARG jenkins_version=latest
MAINTAINER Akram Ben Aissi <abenaiss@redhat.com>
COPY --from=go-init-builder /usr/bin/go-init /usr/bin/go-init
# Jenkins image for OpenShift
#
# This image provides a Jenkins server, primarily intended for integration with
# OpenShift v3.
# OpenShift v4.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove/update OpenShift V3 references from all Dockerfiles.

#
# Volumes:
# * /var/jenkins_home
Expand All @@ -31,31 +30,35 @@ ENV JENKINS_VERSION=2 \
HOME=/var/lib/jenkins \
JENKINS_HOME=/var/lib/jenkins \
JENKINS_UC=https://updates.jenkins.io \
OPENSHIFT_JENKINS_IMAGE_VERSION=4.10 \
OPENSHIFT_JENKINS_IMAGE_VERSION=4.17 \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
INSTALL_JENKINS_VIA_RPMS=false

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

# 8080 for main web interface, 50000 for slave agents
EXPOSE 8080 50000

RUN rm /etc/yum.repos.d/*
COPY contrib/openshift/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
RUN curl http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-Official -o /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS && \
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" && \
DISABLES="" && \
yum $DISABLES -y --setopt=tsflags=nodocs --disableplugin=subscription-manager install epel-release && \
yum $DISABLES -y --setopt=tsflags=nodocs --disableplugin=subscription-manager install $INSTALL_PKGS && \
yum update --excludepkgs redhat-release -y && \
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" && \
yum install -y $INSTALL_PKGS && \
yum update -y && \
rpm -V $INSTALL_PKGS && \
yum clean all && \
mkdir -p /usr/share/openshift/bin/oc-41{2..7} && \
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 && \
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 && \
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 && \
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 && \
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 && \
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 && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
alternatives --set java $(alternatives --display java | grep 'family java-21-openjdk' | cut -d ' ' -f 1) && \
alternatives --set javac $(alternatives --display javac | grep 'family java-21-openjdk' | cut -d ' ' -f 1) && \
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 && \
Expand All @@ -67,7 +70,7 @@ ADD ./contrib/s2i /usr/libexec/s2i
ADD release.version /tmp/release.version

RUN /usr/local/bin/install-jenkins-core-plugins.sh /opt/openshift/bundle-plugins.txt && \
rmdir /var/log/jenkins && \
rm -rf /var/log/jenkins && \
chmod -R 775 /etc/alternatives && \
chmod -R 775 /var/lib/alternatives && \
chmod -R 775 /usr/lib/jvm && \
Expand All @@ -81,6 +84,7 @@ RUN /usr/local/bin/install-jenkins-core-plugins.sh /opt/openshift/bundle-plugins
/usr/local/bin/fix-permissions /var/lib/jenkins && \
/usr/local/bin/fix-permissions /var/log


VOLUME ["/var/lib/jenkins"]

USER 1001
Expand Down
41 changes: 0 additions & 41 deletions 2/cccp.yml

This file was deleted.

1 change: 1 addition & 0 deletions 2/contrib/jenkins/install-jenkins-core-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if [[ "${INSTALL_JENKINS_VIA_RPMS}" == false ]]; then
echo "jenkins.war already exists, skipping upstream RPM installation"
else
echo "Installing jenkins.war from upstream RPM"
mkdir -p /etc/yum.repos.art/ci
curl https://pkg.jenkins.io/rpm-stable/jenkins.repo | tee /etc/yum.repos.d/jenkins.repo /etc/yum.repos.art/ci/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins-ci.org.key
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
Expand Down
2 changes: 1 addition & 1 deletion 2/contrib/jenkins/install-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Usage:
#
# FROM openshift/jenkins-2-centos7
# FROM registry.redhat.io/ocp-tools-4/jenkins-rhel9:v4.17.0
# COPY plugins.txt /plugins.txt
# RUN /usr/local/bin/install-plugins.sh /plugins.txt
#
Expand Down
38 changes: 0 additions & 38 deletions 2/contrib/openshift/CentOS-Base.repo

This file was deleted.

56 changes: 56 additions & 0 deletions 2/contrib/openshift/configuration/init.groovy.d/oc-tools.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import jenkins.model.Jenkins
import hudson.slaves.EnvironmentVariablesNodeProperty
import hudson.slaves.EnvironmentVariablesNodeProperty.Entry
import com.openshift.jenkins.plugins.OpenShiftClientTools
import jenkins.model.Jenkins

println "Configuring node property ..."

def instance = Jenkins.instance

def nodeProps = instance.nodeProperties
def envProp = nodeProps.get(EnvironmentVariablesNodeProperty)

if (envProp == null) {
def newEnv = new EnvironmentVariablesNodeProperty(
new Entry("PATH+OC", "/usr/share/openshift/bin/oc-417"),
)
nodeProps.add(newEnv)
} else {
def envVars = envProp.envVars

envVars.put("PATH+OC", "/usr/share/openshift/bin/oc-417")
}

instance.save()

println "Environment variables updated."

println "Configuring oc tools ..."

def descriptor = Jenkins.instance.getDescriptor(OpenShiftClientTools)

def toolsToAdd = [
"oc-412": "/usr/share/openshift/bin/oc-412",
"oc-413": "/usr/share/openshift/bin/oc-413",
"oc-414": "/usr/share/openshift/bin/oc-414",
"oc-415": "/usr/share/openshift/bin/oc-415",
"oc-416": "/usr/share/openshift/bin/oc-416",
"oc-417": "/usr/share/openshift/bin/oc-417"
]

def existing = descriptor.getInstallations() as List

toolsToAdd.each { name, path ->
if (!existing.any { it.name == name }) {
existing << new OpenShiftClientTools(name, path, [])
println "Added: $name -> $path"
} else {
println "Skipped (already exists): $name"
}
}

descriptor.setInstallations(existing.toArray(new OpenShiftClientTools[0]))
descriptor.save()

println "All done!"
2 changes: 1 addition & 1 deletion 2/test/jenkins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = BeforeSuite(func() {

imageName = os.Getenv("IMAGE_NAME")
if imageName == "" {
imageName = "openshift/jenkins-2-centos7-candidate"
imageName = "openshift/jenkins-2-rhel9-candidate"
}
})

Expand Down
6 changes: 3 additions & 3 deletions ADVANCED_USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A quick recipe of how to do that via layering would be:
* create a Dockerfile with (adjusting the image ref as you see fit)

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

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

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

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

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


Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The master images follow the normal numbering scheme in which the
# major version is used as the directory name and incorporated into
# the image name (jenkins-2-centos7 in this case). For the slave
# the image name (jenkins-2-rhel9 in this case). For the slave
# images we are not versioning them (they actually pull their
# jars from the jenkins master, so they don't have a jenkins version,
# so the only thing we'd version is the maven/nodejs version).
Expand All @@ -13,10 +13,12 @@ VERSIONS="2 slave-base"
BUNDLE_PLUGINS="$(shell pwd)/2/contrib/openshift/bundle-plugins.txt"
REF=$(shell mktemp -d)
JENKINS_WAR="$(shell mktemp -d)/jenkins.war"
ifeq ($(TARGET),rhel8)
ifeq ($(TARGET),rhel9)
OS := rhel9
else ifeq ($(TARGET),rhel8)
OS := rhel8
else
OS := centos8
else
OS := ubi
endif

.PHONY: build
Expand Down
Loading