Skip to content

Commit

Permalink
adding "ct" tool to jenkins-slave-helm (#393)
Browse files Browse the repository at this point in the history
* adding "ct" tool to jenkins-slave-helm

* using scl to install git
  • Loading branch information
deweya authored Jul 17, 2020
1 parent 9b356a6 commit 9485ede
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 0 deletions.
45 changes: 45 additions & 0 deletions jenkins-slaves/jenkins-slave-helm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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
6 changes: 6 additions & 0 deletions jenkins-slaves/jenkins-slave-helm/Jenkinsfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ pipeline {
steps {
sh """
helm help
ct version
ls -l ${HOME}/.ct
git version
python --version
oc version
kubectl version
"""
}
}
Expand Down
10 changes: 10 additions & 0 deletions jenkins-slaves/jenkins-slave-helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 2 additions & 0 deletions jenkins-slaves/jenkins-slave-helm/scl_enable
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unset BASH_ENV PROMPT_COMMAND ENV
source scl_source enable rh-python36 rh-git218
116 changes: 116 additions & 0 deletions jenkins-slaves/jenkins-slave-helm/ubi.repo
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9485ede

Please sign in to comment.