Fix zip entry paths to use forward slashes for Linux compatibility
ZipFile.CreateFromDirectory on Windows produces backslash paths in zip entries. Linux treats backslash as a literal filename character so wwwroot\css\site.css is never found at wwwroot/css/site.css. Build the zip manually with Replace backslash→forward slash on each entry name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vendored
+12
-18
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user