diff --git a/Jenkinsfile b/Jenkinsfile index 8f2af59..d5c4bf4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,39 +1,42 @@ -version="1.0.0" -repository="swr.eu-de.otc.t-systems.com" -tag="latest" -image="swr.eu-de.otc.t-systems.com/omnia-test/${repository}:${version}.${env.BUILD_NUMBER}" -namespace="demo" -def imageName = "swr.eu-de.otc.t-systems.com/omnia-test/test-ci:1.0.0.${env.BUILD_NUMBER}" - -podTemplate(label: 'pod', cloud: 'k8s-config', serviceAccount: 'jenkins-admin', - imagePullSecrets: [ - 'default-secret' - ], - containers: [ - containerTemplate( - name: 'docker', image: 'swr.eu-de.otc.t-systems.com/base-image/docker:dind', ttyEnabled: true, command: 'cat', privileged: true, - envVars: [ - secretEnvVar(key: "PASS", secretName: "docker-reg", secretKey: "pass") - ] - ), - ], -) { - node('pod') { - environment { - FOO = "swr.eu-de.otc.t-systems.com/omnia-test/test-ci:1.0.0.${env.BUILD_NUMBER}" +pipeline { + agent { + kubernetes { + yaml """\ + apiVersion: v1 + kind: Pod + metadata: + name: 'jenkins-slave' + namespace: 'your-namespace' + spec: + containers: + - name: dind + image: swr.eu-de.otc.t-systems.com/base-image/docker:dind + tty: true + imagePullPolicy: Always + imagePullSecrets: + - name: default-secret + env: + - name: PASS + valueFrom: + secretKeyRef: + name: docker-reg + key: docker-reg + """.stripIndent() } + } + stages { + stage('Build Docker Image') { + container('dind') { - stage('Build Docker Image') { - container('docker') { - script { - sh 'echo "FOO is ${env.FOO}"' - sh 'docker login $PASS swr.eu-de.otc.t-systems.com' - sh 'docker build -t ${imageName} .' - sh 'docker push ${image}' - } + echo 'FOO is ${env.BUILD_NUMBER}' + sh """ + image="swr.eu-de.otc.t-systems.com/omnia-test/test-build:latest" + docker login ${PASS} swr.eu-de.otc.t-systems.com + docker build -t ${image} . + docker push ${image} + """ milestone(1) } } - } -} - + } +} \ No newline at end of file diff --git a/Jenkinsfile.old b/Jenkinsfile.old deleted file mode 100644 index c9432bd..0000000 --- a/Jenkinsfile.old +++ /dev/null @@ -1,40 +0,0 @@ -pipeline { - agent { - kubernetes { - yaml """\ - apiVersion: v1 - kind: Pod - metadata: - name: 'jenkins-slave' - namespace: 'your-namespace' - spec: - containers: - - name: docker - image: swr.eu-de.otc.t-systems.com/base-image/docker:dind - tty: true - imagePullPolicy: Always - imagePullSecrets: - - name: default-secret - env: - - name: PASS - valueFrom: - secretKeyRef: - name: docker-reg - key: docker-reg - """.stripIndent() - } - } - stages { - stage('Build Docker Image') { - container('docker') { - sh """ - image="swr.eu-de.otc.t-systems.com/omnia-test/test-build:latest" - docker login ${PASS} swr.eu-de.otc.t-systems.com - docker build -t ${image} . - docker push ${image} - """ - milestone(1) - } - } - } -} \ No newline at end of file