diff --git a/Jenkinsfile b/Jenkinsfile index e110472..b629e42 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,97 +1,104 @@ -podTemplate(yaml: ''' -apiVersion: v1 -kind: Pod -spec: - volumes: - - name: docker-socket - emptyDir: {} - - name: docker-local-certs - configMap: - name: docker-cert - containers: - - name: docker - image: docker:19.03.1 - command: - - sleep - args: - - 99d - volumeMounts: - - name: docker-socket - mountPath: /var/run - - name: docker-daemon - image: docker:19.03.1-dind - securityContext: - privileged: true - volumeMounts: - - name: docker-socket - mountPath: /var/run - - name: docker-local-certs - mountPath: /etc/docker/certs.d/docker.local - - name: python - image: docker.local/ci/python:latest - imagePullPolicy: Always - command: - - sleep - args: - - 99d - - name: helm - image: docker.local/ci/helm:latest - imagePullPolicy: Always - env: - - name: KUBECONFIG - value: /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/kube.config - command: - - sleep - args: - - 99d -''') { - - node(POD_LABEL) { - try { - stage('Git') { - git url: 'https://gyulai.cloud/git/bme/covidok-backend.git', - credentialsId: '1b1c30a0-590d-41d4-b775-bdb90e837bc8' - container('docker') { - stage('Build dev image') { - sh 'docker build -f /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/CoviDok/Dockerfile.CI -t docker.local/bme/covidok:dev /home/jenkins/agent/workspace' - } - stage('Push dev image') { - sh 'docker push docker.local/bme/covidok:dev' - } - } - container('helm') { - stage('Helm lint'){ - sh 'helm lint /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/helm/covidok' - } - stage('Install dev') { - sh '/home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/helm_test.sh /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/helm/covidok' - } - } - container('python') { - stage('API test'){ - sh 'echo python3 -m pytest /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/tests' - } - } - container('docker') { - stage('Push tested image'){ - sh 'docker tag docker.local/bme/covidok:dev docker.local/bme/covidok:latest' - sh 'docker push docker.local/bme/covidok:latest' - } - } - container('helm'){ - stage('Package Helm') { - sh 'helm package /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/helm/covidok' - } - } - stage('Archive chart'){ - archiveArtifacts artifacts: 'covidok*tgz', followSymlinks: false, onlyIfSuccessful: true - } - } - } - finally { - container('helm') { - sh '/home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/cleanup.sh' - } - } - } -} +podTemplate(yaml: ''' +apiVersion: v1 +kind: Pod +spec: + volumes: + - name: docker-socket + emptyDir: {} + - name: docker-local-certs + configMap: + name: docker-cert + containers: + - name: docker + image: docker:19.03.1 + command: + - sleep + args: + - 99d + volumeMounts: + - name: docker-socket + mountPath: /var/run + - name: docker-daemon + image: docker:19.03.1-dind + securityContext: + privileged: true + volumeMounts: + - name: docker-socket + mountPath: /var/run + - name: docker-local-certs + mountPath: /etc/docker/certs.d/docker.local + - name: python + image: docker.local/ci/python:latest + imagePullPolicy: Always + command: + - sleep + args: + - 99d + - name: helm + image: docker.local/ci/helm:latest + imagePullPolicy: Always + env: + - name: KUBECONFIG + value: /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/kube.config + command: + - sleep + args: + - 99d +''') { + + node(POD_LABEL) { + try { + stage('Git') { + git url: 'https://gyulai.cloud/git/bme/covidok-backend.git', + credentialsId: '1b1c30a0-590d-41d4-b775-bdb90e837bc8' + container('docker') { + stage('Build dev image') { + sh 'docker build -f /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/CoviDok/Dockerfile.CI -t docker.local/bme/covidok:dev /home/jenkins/agent/workspace' + } + stage('Push dev image') { + sh 'docker push docker.local/bme/covidok:dev' + } + } + container('helm') { + stage('Helm lint'){ + sh 'helm lint /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/helm/covidok' + } + stage('Install dev') { + sh '/home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/helm_test.sh /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/helm/covidok' + } + } + container('python') { + stage('API test'){ + sh 'echo python3 -m pytest /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/tests' + } + } + container('docker') { + stage('Push tested image'){ + sh 'docker tag docker.local/bme/covidok:dev docker.local/bme/covidok:latest' + sh 'docker push docker.local/bme/covidok:latest' + withCredentials([string(credentialsId: 'docker-dgyulaid-token', variable: 'DOCKER_PASS')]) { + sh ''' + echo "$DOCKER_PASS" | docker login --username dgyulaid --password-stdin + docker tag docker.local/bme/covidok:latest dgyulaid/covidok:latest + docker push dgyulaid/covidok:latest + ''' + } + } + } + container('helm'){ + stage('Package Helm') { + sh 'helm package /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/helm/covidok' + } + } + stage('Archive chart'){ + archiveArtifacts artifacts: 'covidok*tgz', followSymlinks: false, onlyIfSuccessful: true + } + } + } + finally { + container('helm') { + sh '/home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/cleanup.sh' + } + } + } +} diff --git a/ci/ci_values.yaml b/ci/ci_values.yaml index 7974678..d869ea4 100644 --- a/ci/ci_values.yaml +++ b/ci/ci_values.yaml @@ -1,7 +1,8 @@ -# CI values for covidok. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -images: - covidok: - tag: dev +# CI values for covidok. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +images: + covidok: + name: docker.local/bme/covidok + tag: dev diff --git a/helm/covidok/values.yaml b/helm/covidok/values.yaml index f8f9d19..463f6e4 100644 --- a/helm/covidok/values.yaml +++ b/helm/covidok/values.yaml @@ -4,7 +4,7 @@ images: covidok: - name: docker.local/bme/covidok + name: dgyulaid/covidok tag: latest mysql: name: mysql