Create pipeline_lib.groovy

This commit is contained in:
surtexx 2023-11-13 17:20:50 +02:00 committed by GitHub
parent 9157d18f89
commit 5daa969744
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

55
pipeline_lib.groovy Normal file
View file

@ -0,0 +1,55 @@
if(env.CHANGE_ID != null){
pipeline{
agent any
stages {
stage ("build") {
steps {
echo "Running build automation..."
sh './mvnw checkstyle:checkstyle'
sh './mvnw verify'
sh './mvnw clean package -DskipTests=true'
}
}
stage ("Build Docker Image") {
steps {
script{
app = docker.build("surtexx/mr:${GIT_COMMIT[0..7]}", "-f Dockerfile1 .")
}
}
}
stage ("Push Docker Image") {
steps {
script{
docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') {
app.push("${GIT_COMMIT[0..7]}")
app.push("latest")
}
}
}
}
}
}
}
else if(env.BRANCH_NAME == "main"){
pipeline{
agent any
stages{
stage ("Build Docker Image") {
steps {
script{
app = docker.build("surtexx/main", "-f Dockerfile1 .")
}
}
}
stage ("Push Docker Image") {
steps {
script{
docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') {
app.push("latest")
}
}
}
}
}
}
}