From b7fa690ce3f46738a95884303acc01aa94b842fe Mon Sep 17 00:00:00 2001 From: James Lee Date: Thu, 26 Oct 2017 21:16:20 +0100 Subject: [PATCH 1/4] Create Jenkinsfile --- Jenkinsfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..800ffcdded --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,16 @@ +pipeline { + agent any + stages{ + stage('Build'){ + steps { + sh 'mvn clean package' + } + post { + success { + echo 'Now Archiving...' + archiveArtifacts artifacts: '**/target/*.war' + } + } + } + } +} From 0722e2ab9807ff59ddde8b44ff5e42f65df9918c Mon Sep 17 00:00:00 2001 From: James Lee Date: Thu, 26 Oct 2017 21:38:38 +0100 Subject: [PATCH 2/4] Update Jenkinsfile --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 800ffcdded..90aed79465 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,5 +12,10 @@ pipeline { } } } + stage ('Deploy to Staging'){ + steps { + build job: 'Deploy-to-staging' + } + } } } From ba806258c845e1aeef85a2015aaa7bf820a040d7 Mon Sep 17 00:00:00 2001 From: James Lee Date: Thu, 26 Oct 2017 21:45:23 +0100 Subject: [PATCH 3/4] Update Jenkinsfile --- Jenkinsfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 90aed79465..1695ba6a4b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,5 +17,26 @@ pipeline { build job: 'Deploy-to-staging' } } + + stage ('Deploy to Production'){ + steps{ + timeout(time:5, unit:'DAYS'){ + input message:'Approve PRODUCTION Deployment?' + } + + build job: 'Deploy-to-Prod' + } + post { + success { + echo 'Code deployed to Production.' + } + + failure { + echo ' Deployment failed.' + } + } + } + + } } From 6ce16044b660f3255be140eddb8185480345aa24 Mon Sep 17 00:00:00 2001 From: James Lee Date: Fri, 27 Oct 2017 00:05:02 +0100 Subject: [PATCH 4/4] Update Jenkinsfile --- Jenkinsfile | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1695ba6a4b..b56b35de9e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,16 @@ pipeline { agent any - stages{ + + parameters { + string(name: 'tomcat_dev', defaultValue: '35.166.210.154', description: 'Staging Server') + string(name: 'tomcat_prod', defaultValue: '34.209.233.6', description: 'Production Server') + } + + triggers { + pollSCM('* * * * *') + } + +stages{ stage('Build'){ steps { sh 'mvn clean package' @@ -12,31 +22,21 @@ pipeline { } } } - stage ('Deploy to Staging'){ - steps { - build job: 'Deploy-to-staging' - } - } - stage ('Deploy to Production'){ - steps{ - timeout(time:5, unit:'DAYS'){ - input message:'Approve PRODUCTION Deployment?' + stage ('Deployments'){ + parallel{ + stage ('Deploy to Staging'){ + steps { + sh "scp -i /home/jenkins/tomcat-demo.pem **/target/*.war ec2-user@${params.tomcat_dev}:/var/lib/tomcat7/webapps" + } } - build job: 'Deploy-to-Prod' - } - post { - success { - echo 'Code deployed to Production.' - } - - failure { - echo ' Deployment failed.' + stage ("Deploy to Production"){ + steps { + sh "scp -i /home/jenkins/tomcat-demo.pem **/target/*.war ec2-user@${params.tomcat_prod}:/var/lib/tomcat7/webapps" + } } } } - - } }