From 8bd601d2005d0aee2fa515c8c7321dbb4b620575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20S=C4=99k?= Date: Thu, 10 Jan 2019 15:52:55 +0100 Subject: [PATCH] Add cicd pipeline --- cicd/jobs/build.jenkins | 20 ++++++++++++ cicd/pipelines/build.jenkins | 32 +++++++++++++++++++ .../crds/virtuslab_v1alpha1_jenkins_cr.yaml | 12 ++----- 3 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 cicd/jobs/build.jenkins create mode 100644 cicd/pipelines/build.jenkins diff --git a/cicd/jobs/build.jenkins b/cicd/jobs/build.jenkins new file mode 100644 index 00000000..60900600 --- /dev/null +++ b/cicd/jobs/build.jenkins @@ -0,0 +1,20 @@ +#!/usr/bin/env groovy + +pipelineJob('build-jenkins-operator') { + displayName('Build jenkins-operator') + + definition { + cpsScm { + scm { + git { + remote { + url('https://github.com/VirtusLab/jenkins-operator.git') + credentials('jenkins-operator') + } + branches('*/master') + } + } + scriptPath('cicd/pipelines/build.jenkins') + } + } +} \ No newline at end of file diff --git a/cicd/pipelines/build.jenkins b/cicd/pipelines/build.jenkins new file mode 100644 index 00000000..7982577a --- /dev/null +++ b/cicd/pipelines/build.jenkins @@ -0,0 +1,32 @@ +#!/usr/bin/env groovy + +def label = "build-jenkins-operator-${UUID.randomUUID().toString()}" +def home = "${JENKINS_HOME}" +def workspace = "${home}/workspace/build-jenkins-operator" +def workdir = "${workspace}/src/github.com/VirtusLab/jenkins-operator/" + +podTemplate(label: label, + containers: [ + containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:alpine'), + containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true), + ]) { + + node(label) { + dir(workdir) { + stage('Init') { + timeout(time: 3, unit: 'MINUTES') { + checkout scm + } + container('go') { + sh 'apk --no-cache --update add make git gcc libc-dev' + } + } + + stage('Build') { + container('go') { + sh 'make build' + } + } + } + } +} \ No newline at end of file diff --git a/deploy/crds/virtuslab_v1alpha1_jenkins_cr.yaml b/deploy/crds/virtuslab_v1alpha1_jenkins_cr.yaml index 817aa878..e135937d 100644 --- a/deploy/crds/virtuslab_v1alpha1_jenkins_cr.yaml +++ b/deploy/crds/virtuslab_v1alpha1_jenkins_cr.yaml @@ -6,14 +6,8 @@ spec: master: image: jenkins/jenkins seedJobs: - - id: jenkins-operator-e2e + - id: jenkins-operator targets: "cicd/jobs/*.jenkins" - description: "Jenkins Operator e2e tests repository" + description: "Jenkins Operator repository" repositoryBranch: master - repositoryUrl: https://github.com/VirtusLab/jenkins-operator-e2e.git -# Use configuration below if your GitHub repository is private -# repositoryUrl: git@github.com:VirtusLab/jenkins-operator-e2e.git -# privateKey: -# secretKeyRef: -# name: deploy-keys -# key: jenkins-operator-e2e + repositoryUrl: https://github.com/VirtusLab/jenkins-operator.git