我正在尝试使用 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,然后在 Wordpress/Laravel/Magento2 等 PHP 框架中实现相同的概念
接受想法和建议