From d22bbac62c334b4bb34bf8c843eeb87a9614fa9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Thu, 21 Mar 2019 09:26:10 +0100 Subject: [PATCH] [skip travis] update Jenkins support with pre-built images --- support/jenkins/Dockerfile | 23 +++++ support/jenkins/README.md | 9 +- .../jenkins-slave-template-centos.yaml | 89 ------------------- .../jenkins/jenkins-slave-template-rhel.yaml | 3 +- 4 files changed, 27 insertions(+), 97 deletions(-) create mode 100644 support/jenkins/Dockerfile delete mode 100644 support/jenkins/jenkins-slave-template-centos.yaml diff --git a/support/jenkins/Dockerfile b/support/jenkins/Dockerfile new file mode 100644 index 0000000..f50e54a --- /dev/null +++ b/support/jenkins/Dockerfile @@ -0,0 +1,23 @@ +FROM openshift/jenkins-slave-base-centos7:v3.11 + +MAINTAINER Nicolas Masse + +# Labels consumed by Red Hat build service +LABEL name="openshift3/jenkins-agent-ansible-26-centos7" \ + version="v3.11" \ + architecture="x86_64" \ + io.k8s.display-name="Jenkins Agent Ansible" \ + io.k8s.description="The jenkins agent ansible image has the Ansible engine on top of the jenkins slave base image." \ + io.openshift.tags="openshift,jenkins,agent,ansible" + +USER root +RUN yum install -y epel-release && \ + yum install -y 'ansible >= 2.6' && \ + yum install -y python27-python-pip && \ + scl enable python27 "pip install --install-option='--install-purelib=/usr/lib/python2.7/site-packages/' jinja2" && \ + yum clean all && \ + rm -rf /var/cache/yum && \ + chown -R 1001:0 $HOME && \ + chmod -R g+rw $HOME + +USER 1001 diff --git a/support/jenkins/README.md b/support/jenkins/README.md index 76c86e7..8e8e2db 100644 --- a/support/jenkins/README.md +++ b/support/jenkins/README.md @@ -16,8 +16,8 @@ To use this role from Jenkins, you will need to: You can create the Jenkins Slave image for Ansible by executing the following command **in the same project as your Jenkins master**: ```sh -oc create -f https://raw.githubusercontent.com/nmasse-itix/threescale-cicd/master/support/jenkins/jenkins-slave-template-centos.yaml -oc new-app --template=jenkins-ansible-slave +oc import-image jenkins-ansible-slave:master --from=docker.io/nmasse-itix/threescale-cicd:master --confirm +oc annotate is jenkins-ansible-slave role=jenkins-slave --overwrite ``` Alternatively, if you are a Red Hat customer, you can build your images based on RHEL with the following commands: @@ -25,11 +25,6 @@ Alternatively, if you are a Red Hat customer, you can build your images based on ```sh oc create -f https://raw.githubusercontent.com/nmasse-itix/threescale-cicd/master/support/jenkins/jenkins-slave-template-rhel.yaml oc new-app --template=jenkins-ansible-slave -``` - -Wait for the build to finish: - -```sh oc logs -f bc/jenkins-ansible-slave ``` diff --git a/support/jenkins/jenkins-slave-template-centos.yaml b/support/jenkins/jenkins-slave-template-centos.yaml deleted file mode 100644 index 4723479..0000000 --- a/support/jenkins/jenkins-slave-template-centos.yaml +++ /dev/null @@ -1,89 +0,0 @@ -apiVersion: v1 -kind: Template -labels: - template: jenkins-ansible-slave -metadata: - annotations: - description: |- - A Jenkins slave that embeds Ansible 2.6 on CentOS - openshift.io/display-name: Jenkins Slave for Ansible - tags: jenkins - template.openshift.io/documentation-url: https://github.com/nmasse-itix/threescale-cicd - template.openshift.io/long-description: - template.openshift.io/provider-display-name: Nicolas Massé - template.openshift.io/support-url: https://github.com/nmasse-itix/threescale-cicd/issues - name: jenkins-ansible-slave -parameters: -- name: OPENSHIFT_VERSION - value: v3.11 - required: true -objects: -- apiVersion: v1 - kind: ImageStream - metadata: - annotations: - openshift.io/display-name: Jenkins Slave for Ansible - name: jenkins-ansible-slave - spec: - tags: - - name: latest - annotations: - role: jenkins-slave -- apiVersion: v1 - kind: ImageStream - metadata: - name: jenkins-slave-base - spec: - tags: - - name: ${OPENSHIFT_VERSION} - referencePolicy: - type: Local - from: - kind: DockerImage - name: docker.io/openshift/jenkins-slave-base-centos7:${OPENSHIFT_VERSION} - importPolicy: - scheduled: true -- apiVersion: v1 - kind: BuildConfig - metadata: - name: jenkins-ansible-slave - spec: - output: - to: - kind: ImageStreamTag - name: jenkins-ansible-slave:latest - runPolicy: Serial - source: - dockerfile: |- - FROM openshift/jenkins-slave-base-centos7:${OPENSHIFT_VERSION} - - MAINTAINER Nicolas Masse - - # Labels consumed by Red Hat build service - LABEL name="openshift3/jenkins-agent-ansible-26-centos7" \ - version="${OPENSHIFT_VERSION}" \ - architecture="x86_64" \ - io.k8s.display-name="Jenkins Agent Ansible" \ - io.k8s.description="The jenkins agent ansible image has the Ansible engine on top of the jenkins slave base image." \ - io.openshift.tags="openshift,jenkins,agent,ansible" - - USER root - RUN yum install -y ansible && \ - yum install -y python27-python-pip && \ - scl enable python27 "pip install --install-option='--install-purelib=/usr/lib/python2.7/site-packages/' jinja2" && \ - yum clean all && \ - rm -rf /var/cache/yum && \ - chown -R 1001:0 $HOME && \ - chmod -R g+rw $HOME - - USER 1001 - type: Dockerfile - strategy: - dockerStrategy: - from: - kind: ImageStreamTag - name: jenkins-slave-base:${OPENSHIFT_VERSION} - type: Docker - triggers: - - type: ConfigChange - - type: ImageChange diff --git a/support/jenkins/jenkins-slave-template-rhel.yaml b/support/jenkins/jenkins-slave-template-rhel.yaml index 1c41e37..50ae8a3 100644 --- a/support/jenkins/jenkins-slave-template-rhel.yaml +++ b/support/jenkins/jenkins-slave-template-rhel.yaml @@ -70,7 +70,7 @@ objects: io.openshift.tags="openshift,jenkins,agent,ansible" USER root - RUN yum install -y --enablerepo=rhel-7-server-ansible-2.6-rpms ansible && \ + RUN yum install -y --enablerepo=rhel-7-server-ansible-2.6-rpms 'ansible >= 2.6' && \ yum install -y --enablerepo=rhel-server-rhscl-7-rpms python27-python-pip && \ scl enable python27 "pip install --install-option='--install-purelib=/usr/lib/python2.7/site-packages/' jinja2" && \ yum clean all && \ @@ -82,6 +82,7 @@ objects: type: Dockerfile strategy: dockerStrategy: + noCache: true from: kind: ImageStreamTag name: jenkins-slave-base:${OPENSHIFT_VERSION}