cicd-java-spring-boot/Jenkinsfile

47 lines
1.3 KiB
Plaintext
Raw Normal View History

2023-02-01 07:26:49 +00:00
/* pipeline 변수 설정 */
2023-02-01 08:34:23 +00:00
2023-02-01 08:23:05 +00:00
def label = "worker-${UUID.randomUUID().toString()}"
2023-02-01 07:26:49 +00:00
def DATE = new Date();
2023-02-01 08:23:05 +00:00
2023-02-01 08:18:35 +00:00
podTemplate(
2023-02-01 08:23:05 +00:00
label: label,
2023-02-01 08:18:35 +00:00
containers: [
containerTemplate(name: 'gradle', image: 'gradle:7.6-jdk11', command: 'cat', ttyEnabled: true),
],
volumes: [
hostPathVolume(mountPath: '/home/gradle/.gradle', hostPath: '/tmp/jenkins/.gradle'),
]
)
{
2023-02-01 08:23:05 +00:00
node(label) {
2023-02-01 08:18:35 +00:00
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)
stage('Test') {
try {
container('gradle') {
sh """
pwd
echo "GIT_BRANCH=${gitBranch}" >> /etc/environment
echo "GIT_COMMIT=${gitCommit}" >> /etc/environment
gradle test
"""
}
}
catch (exc) {
println "Failed to test - ${currentBuild.fullDisplayName}"
throw(exc)
}
2023-02-01 07:26:49 +00:00
}
2023-02-01 08:18:35 +00:00
2023-02-01 07:11:40 +00:00
stage('Build') {
container('gradle') {
2023-02-01 08:18:35 +00:00
sh "gradle build"
2023-01-31 13:42:28 +00:00
}
}
}
}