【问题标题】:Codepipeline: Deploy only specific files to s3Codepipeline:仅将特定文件部署到 s3
【发布时间】:2020-06-23 06:09:35
【问题描述】:

我在使用 AWS Codepipeline 时遇到问题,我希望 Codepipeline 只部署一个文件,而不是将整个 GitHub 存储库部署到 S3 存储桶。

编辑: 我正在使用 AWS CodeBuild,我的部署 yaml 文件是这样的

version: 0.2
phases:
  install: 
    runtime-versions:
      nodejs: 8
    commands:
      - npm i npm@latest -g
      - pip install --upgrade pip
      - pip install --upgrade awscli
  pre_build:
    commands:
      - npm install redoc-cli -g
  build:
    commands:
      - redoc-cli bundle ./orchestra/api/api.yml
artifacts:
  files:
    - redoc-static.html

【问题讨论】:

  • CodePipeline 是编排,您使用什么服务进行构建和/或部署?

标签: amazon-web-services aws-codepipeline


【解决方案1】:

你快到了。您已经只导出了需要从 CodeBuild 项目(构建规范的工件部分)部署到 S3 的“一个”文件 (redoc-static.html)。现在在您的 CodePipeline 中,在 CodeBuild 阶段,为该操作命名一个新的“输出工件”,然后确保在部署阶段(部署到 S3)使用来自构建阶段的这个输出工件,其中将只包含一个文件(从 CodeBuild 阶段构建工件)。

【讨论】:

    【解决方案2】:

    这将是一个完整的 CodePipeline sn-p,用于在 CodeFormation 中将列为 artifacts: / files: 的内容部署到传递给名为 S3Bucket 的模板参数的现有 S3 存储桶中。可选地,这里的“源”阶段是从链接的 GitHub 存储库中提取的。请注意,ArtifactBucket 是 CodePipeline 在此过程中用作中介的不同“临时”对象

      Pipeline:
        Type: AWS::CodePipeline::Pipeline
        Properties:
          RoleArn: !GetAtt CodePipelineServiceRole.Arn
          ArtifactStore:
            Type: S3
            Location: !Ref ArtifactBucket
          Stages:
            - Name: Source
              Actions:
                - Name: App
                  ActionTypeId:
                    Category: Source
                    Owner: ThirdParty
                    Version: 1
                    Provider: GitHub
                  Configuration:
                    Owner: !Ref GitHubRepoOwner
                    Repo: !Ref GitHubRepo
                    Branch: !Ref GitHubBranch
                    OAuthToken: !Ref GitHubToken
                  OutputArtifacts:
                    - Name: App
                  RunOrder: 1
            - Name: Build
              Actions:
                - Name: Build
                  ActionTypeId:
                    Category: Build
                    Owner: AWS
                    Version: 1
                    Provider: CodeBuild
                  Configuration:
                    ProjectName: !Ref CodeBuildProject
                  InputArtifacts:
                    - Name: App
                  OutputArtifacts:
                    - Name: BuildOutput
                  RunOrder: 1 
            - Name: Deploy
              Actions:
                - Name: Deploy
                  ActionTypeId:
                    Category: Deploy
                    Owner: AWS
                    Version: 1
                    Provider: S3
                  Configuration:
                    BucketName: !Ref S3Bucket
                    Extract: true
                  InputArtifacts:
                    - Name: BuildOutput
                  RunOrder: 1
    

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 2016-12-04
      • 1970-01-01
      • 1970-01-01
      • 2021-11-29
      • 2010-12-16
      • 2021-08-18
      • 2015-04-05
      • 1970-01-01
      相关资源
      最近更新 更多