a
gitea/sample-test/pipeline/head Something is wrong with the build of this commit Details

main
onikolskyy 1 year ago
parent b483945cc0
commit abfc2b9fac

61
Jenkinsfile vendored

@ -1,40 +1,33 @@
pipeline { version="1.0.0"
agent { repository="swr.eu-de.otc.t-systems.com"
kubernetes { tag="latest"
yaml """\ image="swr.eu-de.otc.t-systems.com/omnia-test/${repository}:${version}.${env.BUILD_NUMBER}"
apiVersion: v1 namespace="demo"
kind: Pod
metadata: podTemplate(label: 'pod', cloud: 'kubernetes', serviceAccount: 'jenkins-agent-sa',
name: 'jenkins-slave' imagePullSecrets: [
namespace: 'your-namespace' 'default-secret'
spec: ],
containers: containers: [
- name: docker 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: "docker-reg")
imagePullSecrets: ]
- name: default-secret ),
env: ],
- name: PASS ) {
valueFrom: node('pod') {
secretKeyRef: stage('Build Docker Image') {
name: docker-reg
key: docker-reg
""".stripIndent()
}
}
stages {
stage('Build Docker Image') {
container('docker') { container('docker') {
sh """ sh """
image="swr.eu-de.otc.t-systems.com/omnia-test/test-build:latest" docker login ${env.PASS} swr.eu-de.otc.t-systems.com
docker login ${PASS} swr.eu-de.otc.t-systems.com docker build -t ${image}:${tag} .
docker build -t ${image} . docker push ${image}:${tag}
docker push ${image}
""" """
milestone(1) milestone(1)
} }
} }
} }
} }

@ -1,33 +0,0 @@
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"
podTemplate(label: 'pod', cloud: 'kubernetes', serviceAccount: 'jenkins-agent-sa',
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: "docker-reg")
]
),
],
) {
node('pod') {
stage('Build Docker Image') {
container('docker') {
sh """
docker login ${env.PASS} swr.eu-de.otc.t-systems.com
docker build -t ${image}:${tag} .
docker push ${image}:${tag}
"""
milestone(1)
}
}
}
}

@ -0,0 +1,40 @@
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