/* pipeline 변수 설정 */ def DOCKER_IMAGE_NAME = "twofootdog/project-repo" // 생성하는 Docker image 이름 def DOCKER_IMAGE_TAGS = "batch-visualizer-auth" // 생성하는 Docker image 태그 def NAMESPACE = "ns-project" def VERSION = "${env.BUILD_NUMBER}" def DATE = new Date(); podTemplate( label: 'builder', containers: [ containerTemplate(name: 'gradle', image: 'gradle:7.6-jdk11', command: 'cat', ttyEnabled: true), ], volumes: [ hostPathVolume(mountPath: '/home/gradle/.gradle', hostPath: '/tmp/jenkins/.gradle'), ] ) { node('builder') { 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) } } stage('Build') { container('gradle') { sh "gradle build" } } } }