[英]Azure DevOps - Build and Deploy simple PHP Web App
我正在嘗試使用 CI/CD 並按照此鏈接構建和部署一個帶有 index.php 文件的簡單 php 應用程序。 下面是已經配置好的yaml文件,構建管道執行成功。
# PHP
# Test and package your PHP project.
# Add steps that run tests, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/php
trigger:
- main
variables:
# Azure Resource Manager connection created during pipeline creation
azureSubscription: 'phptestapp-connection'
# Web app name
webAppName: 'phptestapp'
# Resource group
resourceGroupName: 'MyResourceGroup'
# Environment name
environmentName: 'phptestapp'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Archive
displayName: Archive stage
jobs:
- job: Archive
displayName: Archive
pool:
vmImage: $(vmImageName)
steps:
- task: AzureAppServiceSettings@1
inputs:
azureSubscription: $(azureSubscription)
appName: $(webAppName)
resourceGroupName: $(resourceGroupName)
appSettings: |
[
{
"name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
"value": "true"
}
]
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: Deploy stage
dependsOn: Archive
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: $(environmentName)
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp@1
displayName: 'Azure Web App Deploy: PHP Web App'
inputs:
azureSubscription: $(azureSubscription)
appType: webAppLinux
appName: $(webAppName)
runtimeStack: 'PHP|7.2'
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
但是,當我配置並運行發布管道時,它會引發如下異常
> Error: No package found with specified pattern:
> D:\a\r1\a\**\*.zip<br/> Check if the package mentioned in the task is
> published as an artifact in the build or a previous stage and
> downloaded in the current job.
PS 在構建管道 yaml 文件中添加以下內容不會產生任何影響
- task: PublishBuildArtifacts@1
想法是為簡單的 PHP web 應用程序開發 CI/CD,然后將相同的概念實現到 PHP 框架,如 Wordpress/Laravel/Magento2
接受想法和建議
嘗試更換
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
至
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
ArtifactName: 'drop'
publishLocation: 'Container'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.