简体   繁体   English

Azure DevOps - 构建和部署简单的 PHP Web 应用程序

[英]Azure DevOps - Build and Deploy simple PHP Web App

I am trying to build and deploy a simple php app with index.php file using CI/CD and following this link.我正在尝试使用 CI/CD 并按照链接构建和部署一个带有 index.php 文件的简单 php 应用程序。 Below is the yaml file that has been configured and the build pipeline is executed successfully.下面是已经配置好的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

However, when I configure and run release pipeline, it throws exception as below但是,当我配置并运行发布管道时,它会引发如下异常

> 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 Adding below in build pipeline yaml file is not making any impact PS 在构建管道 yaml 文件中添加以下内容不会产生任何影响

- task: PublishBuildArtifacts@1

The idea is to develop a CI/CD for a simple PHP web app and later implement the same concept to PHP framework like Wordpress/Laravel/Magento2想法是为简单的 PHP web 应用程序开发 CI/CD,然后将相同的概念实现到 PHP 框架,如 Wordpress/Laravel/Magento2

Open to ideas and suggestions接受想法和建议

Try to replace尝试更换

- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
  artifact: drop

to

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    ArtifactName: 'drop'
    publishLocation: 'Container'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM