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.
This commit is contained in:
Jie Shen 2019-06-24 15:41:27 +08:00 committed by GitHub
parent e157f200f8
commit ae1f4a804c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 0 deletions

22
Jenkinsfile vendored Normal file
View file

@ -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'
}
}

48
Jenkinsfile-bluegreen Normal file
View file

@ -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
}
}

11
web.config Normal file
View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\petclinic.jar&quot;">
</httpPlatform>
</system.webServer>
</configuration>