a
test/pipeline/head There was a failure building this commit Details

main
onikolskyy 1 year ago
parent 060fab23e7
commit 747d577c13

69
Jenkinsfile vendored

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

@ -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)
}
}
}
}
Loading…
Cancel
Save