2023-02-01 11:07:00 +00:00
|
|
|
def label = "worker-${UUID.randomUUID().toString()}"
|
|
|
|
|
|
|
|
podTemplate(
|
|
|
|
label: label
|
|
|
|
containers: [
|
|
|
|
containerTemplate(
|
|
|
|
name: 'gradle',
|
|
|
|
image: 'gradle:7.6.0-jdk11',
|
|
|
|
command: 'sleep',
|
|
|
|
args: '30d'
|
2023-02-01 09:17:31 +00:00
|
|
|
)
|
2023-02-01 11:07:00 +00:00
|
|
|
],
|
|
|
|
volumes: [
|
|
|
|
hostPathVolume(mountPath: '/home/gradle/.gradle', hostPath: '/tmp/jenkins/.gradle')
|
|
|
|
]
|
|
|
|
)
|
|
|
|
{
|
|
|
|
node(label) {
|
|
|
|
def myRepo = checkout scm
|
|
|
|
def gitCommit = myRepo.GIT_COMMIT
|
|
|
|
def gitBranch = myRepo.GIT_BRANCH
|
|
|
|
def shortGitCommit = "${gitCommit[0..10]}"
|
|
|
|
def previousGitCommit = sh(script: "git rev-parse ${gitCommit}~", returnStdout: true)
|
2023-02-01 08:34:23 +00:00
|
|
|
|
2023-02-01 11:07:00 +00:00
|
|
|
stage('Test') {
|
|
|
|
try {
|
|
|
|
container('gradle') {
|
|
|
|
sh """
|
|
|
|
pwd
|
|
|
|
echo "GIT_BRANCH=${gitBranch}" >> /etc/environment
|
|
|
|
echo "GIT_COMMIT=${gitCommit}" >> /etc/environment
|
|
|
|
gradle test
|
|
|
|
"""
|
2023-02-01 08:18:35 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-01 11:07:00 +00:00
|
|
|
catch (exc) {
|
|
|
|
println "Failed to test - ${currentBuild.fullDisplayName}"
|
|
|
|
throw(exc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Build') {
|
|
|
|
container('gradle') {
|
|
|
|
sh "gradle build"
|
|
|
|
}
|
2023-02-01 07:26:49 +00:00
|
|
|
}
|
2023-01-31 13:42:28 +00:00
|
|
|
}
|
2023-02-01 09:48:49 +00:00
|
|
|
}
|