environment test

This commit is contained in:
crusader 2023-02-01 14:11:40 +00:00
parent 27183530cc
commit 05865e1cd2
2 changed files with 20 additions and 0 deletions

4
Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM openjdk:11
ARG JAR_NAME
COPY build/libs/${JAR_NAME} ${JAR_NAME}
ENTRYPOINT ["java", "-jar", "/${JAR_NAME}"]

16
Jenkinsfile vendored
View File

@ -40,6 +40,7 @@ podTemplate(
def gitBranch = myRepo.GIT_BRANCH
def shortGitCommit = "${gitCommit[0..10]}"
def previousGitCommit = sh(script: "git rev-parse ${gitCommit}~", returnStdout: true)
def docker_registry_url = "harboar.loafle.net"
stage('Test') {
try {
@ -57,11 +58,26 @@ podTemplate(
throw(exc)
}
}
stage('Build') {
container('gradle') {
sh "gradle build"
}
}
stage('Create Docker images') {
container('docker') {
withCredentials([[$class: 'UsernamePasswordMultiBinding',
credentialsId: 'harbor.loafle.net',
usernameVariable: 'HARBOR_USER',
passwordVariable: 'HARBOR_PASSWORD']]) {
sh """
docker login -u ${HARBOR_USER} -p ${HARBOR_PASSWORD} ${docker_registry_url}
docker build -t ${docker_registry_url}/prototype/cicd-java-spring-boot:${gitCommit} -f Dockerfile.arg --build-arg JAR_NAME="cicd-${gitCommit}.jar" .
docker push ${docker_registry_url}/prototype/cicd-java-spring-boot:${gitCommit}
"""
}
}
}
}
}