diff --git a/Jenkinsfile b/Jenkinsfile index 4228996..e3d9662 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,7 +53,18 @@ pipeline { stage('Deploy to Azure') { steps { - bat 'powershell -Command "Add-Type -Assembly System.IO.Compression.FileSystem; if (Test-Path deploy.zip) { Remove-Item deploy.zip }; [System.IO.Compression.ZipFile]::CreateFromDirectory(\'publish\', \'deploy.zip\')"' + powershell ''' + Add-Type -Assembly System.IO.Compression.FileSystem + if (Test-Path deploy.zip) { Remove-Item deploy.zip } + $publishDir = (Resolve-Path "publish").Path + $zip = [System.IO.Compression.ZipFile]::Open("deploy.zip", "Create") + Get-ChildItem -Path $publishDir -Recurse -File | ForEach-Object { + $entryName = $_.FullName.Substring($publishDir.Length + 1).Replace("\\", "/") + [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip, $_.FullName, $entryName, "Optimal") | Out-Null + } + $zip.Dispose() + Write-Host "Created deploy.zip with $(($zip = [System.IO.Compression.ZipFile]::OpenRead('deploy.zip'); $zip.Entries.Count; $zip.Dispose())) entries using forward-slash paths" + ''' withCredentials([azureServicePrincipal( credentialsId: 'azure-pcl', subscriptionIdVariable: 'AZ_SUB_ID', @@ -63,27 +74,10 @@ pipeline { )]) { bat 'az login --service-principal -u "%AZ_CLIENT_ID%" -p "%AZ_CLIENT_SECRET%" --tenant "%AZ_TENANT_ID%" --output none' bat 'az account set --subscription "%AZ_SUB_ID%"' - bat 'az webapp stop --resource-group rg-powdercoatinglogix-prod --name linuxpcl' bat 'az webapp deploy --resource-group rg-powdercoatinglogix-prod --name linuxpcl --src-path deploy.zip --type zip --async true' - bat 'az webapp start --resource-group rg-powdercoatinglogix-prod --name linuxpcl' bat 'az logout' } } - post { - failure { - withCredentials([azureServicePrincipal( - credentialsId: 'azure-pcl', - subscriptionIdVariable: 'AZ_SUB_ID', - clientIdVariable: 'AZ_CLIENT_ID', - clientSecretVariable: 'AZ_CLIENT_SECRET', - tenantIdVariable: 'AZ_TENANT_ID' - )]) { - bat 'az login --service-principal -u "%AZ_CLIENT_ID%" -p "%AZ_CLIENT_SECRET%" --tenant "%AZ_TENANT_ID%" --output none' - bat 'az webapp start --resource-group rg-powdercoatinglogix-prod --name linuxpcl' - bat 'az logout' - } - } - } } stage('Health Check') {