diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..4089760 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,59 @@ +pipeline { + agent any + + environment { + HARBOR_HOST = "harbor.dinauer.dev" + PROJECT = "metrics-service" + REPO = "backend" + } + + stages { + stage('Set Image Name') { + steps { + script { + env.IMAGE = "${env.HARBOR_HOST}/${env.PROJECT}/${env.REPO}:${env.BUILD_NUMBER}" + env.LATEST = "${env.HARBOR_HOST}/${env.PROJECT}/${env.REPO}:latest" + } + } + } + stage('Build Quarkus application') { + steps { + script { + sh 'mvn clean package' + } + } + } + stage('Build Docker Image') { + steps { + script { + sh "docker build --no-cache -t ${env.IMAGE} ." + sh "docker tag ${env.IMAGE} ${env.LATEST}" + } + } + } + stage('Push Image to Docker Hub') { + steps { + script { + withCredentials([usernamePassword(credentialsId: 'harbor', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + sh "echo ${PASSWORD} | docker login ${env.HARBOR_HOST} -u ${USERNAME} --password-stdin" + sh "docker push ${env.IMAGE} && docker push ${env.LATEST}" + sh "docker logout" + } + } + } + } + stage('Remove image from host') { + steps { + script { + sh "docker image rm --force ${env.IMAGE}" + } + } + } + } + + post { + always { + cleanWs() + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 642f91c..a86fb86 100644 --- a/pom.xml +++ b/pom.xml @@ -134,32 +134,12 @@ - - org.apache.maven.plugins - maven-antrun-plugin - 3.1.0 - - - validate - - run - - - - - - - - - net.revelc.code.formatter formatter-maven-plugin 2.29.0 - format.xml + https://git.dinauer.dev/andreas.dinauer/formatter/raw/branch/main/format.xml LF UTF-8