environment test

This commit is contained in:
crusader 2023-02-01 08:18:35 +00:00
parent 5de8f6c5f0
commit 6c4420e5b4

45
Jenkinsfile vendored
View File

@ -5,21 +5,44 @@ 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'),
]) {
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') {
stage('Checkout') {
checkout scm // gitlab으로부터 소스 다운
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') {
/* 도커 이미지를 활용하여 gradle 빌드를 수행하여 ./build/libs에 jar파일 생성 */
sh "gradle -x test build"
sh "gradle build"
}
}
}