繁体   English   中英

使用 CI/CD 管道将 PHP 应用程序从 Azure DevOps 部署到 AWS

[英]Deploy PHP application from Azure DevOps to AWS using CI/CD pipeline

我能够使用 CI/CD 管道 YAML 文件将 ASP.net 应用程序从 Azure DevOps 部署到 AWS 环境。 我稍微修改了 ASP.net YAML 文件并尝试部署 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:
- master

pool:
  vmImage: ubuntu-latest

variables:
  phpVersion: 7.2

steps:
- script: |
    sudo update-alternatives --set php /usr/bin/php$(phpVersion)
    sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)
    sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)
    sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)
    sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)
    php -version
  displayName: 'Use PHP version $(phpVersion)'

- script: composer install --no-interaction --prefer-dist
  displayName: 'composer install'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'
- task: BeanstalkDeployApplication@1
  inputs:
    awsCredentials: 'AWS_Creds'
    regionName: 'us-north-1'
    applicationName: 'app_name'
    environmentName: 'env_name'
    description: 'New Build from Azure DevOps'
    applicationType: 'version'
    webDeploymentArchive: '$(build.artifactStagingDirectory)/WebApp.zip'

运行上述管道脚本时出现以下错误。

Starting: composer install
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.182.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
composer install --no-interaction --prefer-dist
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/f5188f9d-a102-4093-ad5d-0acaaa110763.sh
Composer could not find a composer.json file in /home/vsts/work/1/s
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
##[error]Bash exited with code '1'.
Finishing: composer install

Composer 在 /home/vsts/work/1/s 中找不到 composer.json 文件

/home/vsts/work/1/s是您的存储库将被检出的工作目录。 如果您的 composer.json 文件在存储库的根目录下,即其路径为repsotiory_name/composer.json ,则命令行任务将成功运行该命令composer install --no-interaction --prefer-dist

如果composer.json文件在repository的子目录下,则需要将当前目录切换到其文件路径。 例如,它的路径是repsotiory_name/subfolder/composer.json ,下面的脚本应该按预期工作。

- script: |
    cd subfolder
    composer install --no-interaction --prefer-dist
  displayName: 'composer install'

暂无
暂无

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

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