diff --git a/jenkins-slaves/jenkins-slave-helm/Dockerfile b/jenkins-slaves/jenkins-slave-helm/Dockerfile index adc6a6961..cffd8f84c 100644 --- a/jenkins-slaves/jenkins-slave-helm/Dockerfile +++ b/jenkins-slaves/jenkins-slave-helm/Dockerfile @@ -2,7 +2,15 @@ FROM quay.io/openshift/origin-jenkins-agent-base:4.4 ARG VERSION=3.2.0 ARG YQ_VERSION=3.3.0 +ARG CT_VERSION=3.0.0-rc.1 +ARG OPENSHIFT_CLIENT_VERSION=4.4.13 +## Required in order to avoid ct "ascii codec can't encode character" error +ENV PYTHONIOENCODING=utf-8 + +COPY ubi.repo /etc/yum.repos.d/ + +## Install helm and yq RUN curl -skL -o /tmp/helm.tar.gz https://get.helm.sh/helm-v${VERSION}-linux-amd64.tar.gz && \ tar -C /tmp -xzf /tmp/helm.tar.gz && \ mv /tmp/linux-amd64/helm /usr/local/bin && \ @@ -12,4 +20,41 @@ RUN curl -skL -o /tmp/helm.tar.gz https://get.helm.sh/helm-v${VERSION}-linux-amd curl -sL https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -o /usr/local/bin/yq && \ chmod -R 775 /usr/local/bin/yq +## Install ct +RUN curl -sL -o /tmp/chart-testing.tar.gz https://github.com/helm/chart-testing/releases/download/v${CT_VERSION}/chart-testing_${CT_VERSION}_linux_amd64.tar.gz && \ + mkdir /tmp/chart-testing && \ + tar -C /tmp/chart-testing -zxf /tmp/chart-testing.tar.gz && \ + mv /tmp/chart-testing/ct /usr/local/bin && \ + chmod 775 /usr/local/bin/ct && \ + rm /tmp/chart-testing.tar.gz && \ + mkdir ${HOME}/.ct && \ + mv /tmp/chart-testing/etc/chart_schema.yaml /tmp/chart-testing/etc/lintconf.yaml ${HOME}/.ct/ && \ + rm -rf /tmp/chart-testing + +## Install python 3.6, yamale, and yamllint +RUN INSTALL_PKGS="rh-python36 rh-python36-python-pip" && \ + yum -y --setopt=tsflags=nodocs --disablerepo='rhel-*' install $INSTALL_PKGS && \ + yum -y clean all && \ + source scl_source enable rh-python36 && \ + python3 -m pip install yamale==3.0.1 && \ + python3 -m pip install yamllint==1.24.1 + +## Install git > 2.17 (ubi repos don't provide this) +RUN yum -y remove git* && \ + yum -y --disablerepo='rhel-*' install --setopt=tsflags=nodocs centos-release-scl && \ + yum -y --disablerepo='rhel-*' install --setopt=tsflags=nodocs rh-git218 && \ + yum -y clean all + +## Install oc and kubectl +RUN curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OPENSHIFT_CLIENT_VERSION}/openshift-client-linux-${OPENSHIFT_CLIENT_VERSION}.tar.gz \ + | tar zxf - -C /usr/local/bin oc kubectl + +## Persistently enable software collections +RUN mkdir /usr/share/container-scripts +COPY scl_enable /usr/share/container-scripts +RUN chmod 555 /usr/share/container-scripts/scl_enable +ENV BASH_ENV=/usr/share/container-scripts/scl_enable \ + ENV=/usr/share/container-scripts/scl_enable \ + PROMPT_COMMAND=". /usr/share/container-scripts/scl_enable" + USER 1001 diff --git a/jenkins-slaves/jenkins-slave-helm/Jenkinsfile.test b/jenkins-slaves/jenkins-slave-helm/Jenkinsfile.test index c9edaf898..9ab3666cd 100644 --- a/jenkins-slaves/jenkins-slave-helm/Jenkinsfile.test +++ b/jenkins-slaves/jenkins-slave-helm/Jenkinsfile.test @@ -8,6 +8,12 @@ pipeline { steps { sh """ helm help + ct version + ls -l ${HOME}/.ct + git version + python --version + oc version + kubectl version """ } } diff --git a/jenkins-slaves/jenkins-slave-helm/README.md b/jenkins-slaves/jenkins-slave-helm/README.md index 4c92ecade..5a903a0d9 100644 --- a/jenkins-slaves/jenkins-slave-helm/README.md +++ b/jenkins-slaves/jenkins-slave-helm/README.md @@ -11,3 +11,13 @@ oc process -f ../../.openshift/templates/jenkins-slave-generic-template.yml \ | oc create -n openshift -f - ``` For all params see the list in the `../../.openshift/templates/jenkins-slave-generic-template.yml` or run `oc process --parameters -f ../../.openshift/templates/jenkins-slave-generic-template.yml`. + +## Note about ct +`ct` (aka `Chart Testing`) is a tool for testing Helm charts in a monorepo. More information about this tool can be found at the project's [GitHub page](https://github.com/helm/chart-testing). + +When using `ct`, you may encounter the following error in a multibranch pipeline job: +``` +Error linting charts: Error identifying charts to process: Error running process: exit status 128 +``` + +Follow [this GitHub issue](https://github.com/helm/chart-testing/issues/186#issuecomment-615995590) if you run into this error. This is caused by shallow cloning, which should be disabled to fix this error. diff --git a/jenkins-slaves/jenkins-slave-helm/scl_enable b/jenkins-slaves/jenkins-slave-helm/scl_enable new file mode 100644 index 000000000..b726435f4 --- /dev/null +++ b/jenkins-slaves/jenkins-slave-helm/scl_enable @@ -0,0 +1,2 @@ +unset BASH_ENV PROMPT_COMMAND ENV +source scl_source enable rh-python36 rh-git218 \ No newline at end of file diff --git a/jenkins-slaves/jenkins-slave-helm/ubi.repo b/jenkins-slaves/jenkins-slave-helm/ubi.repo new file mode 100644 index 000000000..8c5936596 --- /dev/null +++ b/jenkins-slaves/jenkins-slave-helm/ubi.repo @@ -0,0 +1,116 @@ +[ubi-7] +name = Red Hat Universal Base Image 7 Server (RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/os +enabled = 1 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-server-debug-rpms] +name = Red Hat Universal Base Image 7 Server (Debug RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/debug +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-server-source-rpms] +name = Red Hat Universal Base Image 7 Server (Source RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/source/SRPMS +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-server-optional-rpms] +name = Red Hat Universal Base Image 7 Server - Optional (RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/optional/os +enabled = 1 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-server-optional-debug-rpms] +name = Red Hat Universal Base Image 7 Server - Optional (Debug RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/optional/debug +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-server-optional-source-rpms] +name = Red Hat Universal Base Image 7 Server - Optional (Source RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/optional/source/SRPMS +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-server-extras-rpms] +name = Red Hat Universal Base Image 7 Server - Extras (RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/extras/os +enabled = 1 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-server-extras-debug-rpms] +name = Red Hat Universal Base Image 7 Server - Extras (Debug RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/extras/debug +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-server-extras-source-rpms] +name = Red Hat Universal Base Image 7 Server - Extras (Source RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/extras/source/SRPMS +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-rhah] +name = Red Hat Universal Base Image Atomic Host (RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/atomic/7/7Server/$basearch/os +enabled = 1 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-rhah-debug] +name = Red Hat Universal Base Image Atomic Host (Debug RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/atomic/7/7Server/$basearch/debug +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-7-rhah-source] +name = Red Hat Universal Base Image Atomic Host (Source RPMs) +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/atomic/7/7Server/$basearch/source/SRPMS +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-server-rhscl-7-rpms] +name = Red Hat Software Collections RPMs for Red Hat Universal Base Image 7 Server +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/rhscl/1/os +enabled = 1 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-server-rhscl-7-debug-rpms] +name = Red Hat Software Collections Debug RPMs for Red Hat Universal Base Image 7 Server +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/rhscl/1/debug +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[ubi-server-rhscl-7-source-rpms] +name = Red Hat Software Collections Source RPMs for Red Hat Universal Base Image 7 Server +baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/$basearch/rhscl/1/source/SRPMS +enabled = 0 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +gpgcheck = 1 + +[centos-mirror] +name = CentOS Mirror +baseurl = http://mirror.centos.org/centos/7/os/x86_64/ +enabled = 1 +gpgcheck = 0 + +[centos-extras] +name = CentOS Extras +baseurl = http://mirror.centos.org/centos/7/extras/x86_64/ +enabled = 1 +gpgcheck = 0 \ No newline at end of file