diff --git a/Jenkinsfile b/Jenkinsfile index f2949fe..22e07da 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,45 +1,33 @@ -def gv - pipeline { agent any - parameters { - choice(name: 'VERSION', choices: ['1.1.0', '1.2.0', '1.3.0'], description: '') - booleanParam(name: 'executeTests', defaultValue: true, description: '') + tools { + maven 'Maven' } stages { - stage("init") { + stage("build jar") { steps { script { - gv = load "script.groovy" + echo "building the application..." + sh 'mvn package' } } } - stage("build") { + stage("build image") { steps { script { - gv.buildApp() - } - } - } - stage("test") { - when { - expression { - params.executeTests - } - } - steps { - script { - gv.testApp() + 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" + sh 'docker push nanajanashia/demo-app:jma-2.0' + } } } } stage("deploy") { steps { script { - env.ENV = input message: "Select the environment to deploy to", ok: "Done", parameters: [choice(name: 'ONE', choices: ['dev', 'staging', 'prod'], description: '')] - - gv.deployApp() - echo "Deploying to ${ENV}" + echo "deploying the application..." } } }