mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 15:25:49 +00:00
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:
parent
e157f200f8
commit
ae1f4a804c
3 changed files with 81 additions and 0 deletions
22
Jenkinsfile
vendored
Normal file
22
Jenkinsfile
vendored
Normal 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
48
Jenkinsfile-bluegreen
Normal 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
11
web.config
Normal 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 "%HOME%\site\wwwroot\petclinic.jar"">
|
||||||
|
</httpPlatform>
|
||||||
|
</system.webServer>
|
||||||
|
</configuration>
|
Loading…
Reference in a new issue