ASP.NET Core + AWS Elastic Beanstalk + Bitbucket Pipeline

4
我们如何使用Bitbucket Pipelines来更新AWS Elastic Beanstalk上的ASP.NET Core网站?
1个回答

1

我知道这个回答有些晚了,但是我几天前做了同样的事情,下面是我的示例:

首先你需要在Bitbucket中启用管道功能,选择.NET CORE。在bitbucket-pipelines.yml文件中,你需要写入以下内容:

image: microsoft/dotnet:sdk
  pipelines:
    branches:
      staging:
        - step:
          name: build publish prepare and zip
          caches:
            - dotnetcore
          script:
            - apt-get update && apt-get install --yes zip
            - export PROJECT_NAME=<your-project-name>
            - dotnet restore
            - dotnet build $PROJECT_NAME
            - dotnet publish --self-contained --runtime win-x64 --configuration Release 
      
            - zip -j site.zip /opt/atlassian/pipelines/agent/build/<your-project-name>/bin/Release/netcoreapp2.0/win-x64/publish/*  -x aws-windows-deployment-manifest.json
            - zip -r -j application.zip site.zip /opt/atlassian/pipelines/agent/build/<your-project-name>/bin/Release/netcoreapp2.0/win-x64/publish/aws-windows-deployment-manifest.json 
          artifacts:
            - application.zip

        - step:
          name: upload to elasticbeanstalk
          script:
            - pipe: atlassian/aws-elasticbeanstalk-deploy:0.5.0
            variables:
              APPLICATION_NAME: '<application-name>'
              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
              AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
              #COMMAND: 'upload-only'
              ZIP_FILE: 'application.zip'
              ENVIRONMENT_NAME: '<environment-name>'
              WAIT: 'true'

在设置 -> 流水线 -> 变量 中,您需要设置 AWS 密钥:访问密钥和区域,这将由 $ ($AWS_SECRET_ACCESS_KEY) 使用。

此外,您还需要创建 S3 存储桶“-elsticbeanstalk-deployments”(如果您没有创建它,在环境尝试上传您的 Zip 时,它将显示“未找到”存储桶名称的错误,因此只需复制名称并在 S3 中创建即可)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接