Update Jenkinsfile

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

92
Jenkinsfile vendored
View file

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