👷 Add Pipeline
This commit is contained in:
parent
d3ac15df2c
commit
385a33a8f6
59
Jenkinsfile
vendored
Normal file
59
Jenkinsfile
vendored
Normal file
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
pom.xml
22
pom.xml
@ -134,32 +134,12 @@
|
|||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
|
||||||
<version>3.1.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>validate</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>run</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<target>
|
|
||||||
<get src="https://git.dinauer.dev/andreas.dinauer/formatter/raw/branch/main/format.xml"
|
|
||||||
dest="format.xml"
|
|
||||||
usetimestamp="true"/>
|
|
||||||
</target>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.revelc.code.formatter</groupId>
|
<groupId>net.revelc.code.formatter</groupId>
|
||||||
<artifactId>formatter-maven-plugin</artifactId>
|
<artifactId>formatter-maven-plugin</artifactId>
|
||||||
<version>2.29.0</version>
|
<version>2.29.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configFile>format.xml</configFile>
|
<configFile>https://git.dinauer.dev/andreas.dinauer/formatter/raw/branch/main/format.xml</configFile>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user