mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
da0935c0e5
* Patch Urls * fix test
1.6 KiB
1.6 KiB
${docGenStepName}
${docGenDescription}
${docGenParameters}
Kubernetes support
If the Jenkins is setup on a Kubernetes cluster, then you can execute the closure inside a container of a pod by setting an environment variable ON_K8S
to true
. However, it will ignore containerPortMappings
, dockerOptions
and dockerVolumeBind
values.
${docGenConfiguration}
${docJenkinsPluginDependencies}
Side effects
none
Exceptions
none
Example 1: Run closure inside a docker container
dockerExecute(dockerImage: 'maven:3.5-jdk-7'){
sh "mvn clean install"
}
Example 2: Run closure inside a container in a kubernetes pod
# set environment variable
export ON_K8S=true"
dockerExecute(script: this, dockerImage: 'maven:3.5-jdk-7'){
sh "mvn clean install"
}
In the above example, the dockerEcecute
step will internally invoke dockerExecuteOnKubernetes step and execute the closure inside a pod.
Example 3: Run closure inside a container which is attached to a sidecar container (as for example used in seleniumExecuteTests
dockerExecute(
script: script,
containerPortMappings: [containerPortMappings:'selenium/standalone-chrome':[containerPort: 4444, hostPort: 4444]],
dockerImage: 'node:8-stretch',
dockerName: 'node',
dockerWorkspace: '/home/node',
sidecarImage: 'selenium/standalone-chrome',
sidecarName: 'selenium',
) {
git url: 'https://github.com/XXXXX/WebDriverIOTest.git'
sh '''npm install
node index.js
'''
}