From ae1f4a804c14f635191e67a6f92e1e6f1e8f4b53 Mon Sep 17 00:00:00 2001 From: Jie Shen Date: Mon, 24 Jun 2019 15:41:27 +0800 Subject: [PATCH] Add Jenkinsfile (#1) * Add Jenkinsfile * Use zip deployment * Add basic bluegreen jenkinsfile * Fix bug * Add confirm stage * Add app change * Revert "Add app change" This reverts commit 84c904b75fd38956e37f64c2b167f29493d4c8a4. --- Jenkinsfile | 22 ++++++++++++++++++++ Jenkinsfile-bluegreen | 48 +++++++++++++++++++++++++++++++++++++++++++ web.config | 11 ++++++++++ 3 files changed, 81 insertions(+) create mode 100644 Jenkinsfile create mode 100644 Jenkinsfile-bluegreen create mode 100644 web.config diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..e786f9191 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,22 @@ +node('master') { + stage('init') { + checkout scm + } + + stage('image build') { + sh ''' + ./mvnw clean package + cd target + mv *.jar petclinic.jar + cp ../web.config web.config + zip petclinic.zip web.config petclinic.jar + ''' + } + + stage('deploy') { + azureWebAppPublish appName: env.APP_NAME, + azureCredentialsId: env.CRED_ID, + resourceGroup: env.RESOURCE_GROUP, + filePath: 'target/*.zip' + } +} \ No newline at end of file diff --git a/Jenkinsfile-bluegreen b/Jenkinsfile-bluegreen new file mode 100644 index 000000000..6bab99a25 --- /dev/null +++ b/Jenkinsfile-bluegreen @@ -0,0 +1,48 @@ +def userInput + +node('master') { + stage('init') { + checkout scm + } + + stage('image build') { + sh ''' + ./mvnw clean package + cd target + mv *.jar petclinic.jar + cp ../web.config web.config + zip petclinic.zip web.config petclinic.jar + ''' + } + + stage('preview') { + azureWebAppPublish appName: env.APP_NAME, + azureCredentialsId: env.CRED_ID, + resourceGroup: env.RESOURCE_GROUP, + filePath: 'target/*.zip', + slotName: 'preview' + } + + stage('confirm swap slots') { + try { + userInput = input( + id: 'Proceed1', message: 'Do you want to swap slots?', parameters: [ + [$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you want to swap the slots'] + ]) + } catch(err) { // input false + echo "Aborted" + } + } + + if (userInput == true) { + stage('swap slots') { + azureWebAppSwapSlots appName: env.APP_NAME, + azureCredentialsId: env.CRED_ID, + resourceGroup: env.RESOURCE_GROUP, + sourceSlotName: 'production', + targetSlotName: 'preview' + } + } else { + // Send a notification + } +} \ No newline at end of file diff --git a/web.config b/web.config new file mode 100644 index 000000000..113edef24 --- /dev/null +++ b/web.config @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file