Update Jenkinsfile

This commit is contained in:
Nana Janashia
2020-11-06 11:17:00 +00:00
parent cdacbeeec4
commit 845783dbc6

38
Jenkinsfile vendored
View File

@@ -1,45 +1,33 @@
def gv
pipeline { pipeline {
agent any agent any
parameters { tools {
choice(name: 'VERSION', choices: ['1.1.0', '1.2.0', '1.3.0'], description: '') maven 'Maven'
booleanParam(name: 'executeTests', defaultValue: true, description: '')
} }
stages { stages {
stage("init") { stage("build jar") {
steps { steps {
script { script {
gv = load "script.groovy" echo "building the application..."
sh 'mvn package'
} }
} }
} }
stage("build") { stage("build image") {
steps { steps {
script { script {
gv.buildApp() echo "building the docker image..."
} withCredentials([usernamePassword(credentialsId: 'docker-hub-repo', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
} sh 'docker build -t nanajanashia/demo-app:jma-2.0 .'
} sh "echo $PASS | docker login -u $USER --password-stdin"
stage("test") { sh 'docker push nanajanashia/demo-app:jma-2.0'
when { }
expression {
params.executeTests
}
}
steps {
script {
gv.testApp()
} }
} }
} }
stage("deploy") { stage("deploy") {
steps { steps {
script { script {
env.ENV = input message: "Select the environment to deploy to", ok: "Done", parameters: [choice(name: 'ONE', choices: ['dev', 'staging', 'prod'], description: '')] echo "deploying the application..."
gv.deployApp()
echo "Deploying to ${ENV}"
} }
} }
} }