diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100755 index 0000000..ed4d827 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,47 @@ +pipeline { + agent any + + stages { + stage('Set Image Name') { + steps { + script { + env.TAG = "${env.BUILD_NUMBER}" + env.REFERENCE = "harbor.dinauer.dev/oidc-proxy/core" + env.IMAGE = "${env.REFERENCE}:${env.BUILD_NUMBER}"; + } + } + } + stage('Build Quarkus application') { + steps { + script { + sh './mvnw clean package -DskipTests=true' + } + } + } + stage('Build Docker Image') { + steps { + script { + sh "docker build --no-cache -t ${env.IMAGE} -f src/main/docker/Dockerfile.jvm ." + } + } + } + stage('Push Image to Docker Hub') { + steps { + script { + withCredentials([usernamePassword(credentialsId: 'harbor', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + sh 'echo ${PASSWORD} | docker login harbor.dinauer.dev -u ${USERNAME} --password-stdin' + sh "docker push ${env.IMAGE}" + sh "docker logout" + } + } + } + } + stage('Remove image from host') { + steps { + script { + sh "docker image rm --force ${env.IMAGE}" + } + } + } + } +} \ No newline at end of file