【问题标题】:How to make Circle CI upload and deploy an image on AWS ECS only after tests are success?测试成功后,如何让 Circle CI 在 AWS ECS 上上传和部署镜像?
【发布时间】:2020-11-04 02:47:45
【问题描述】:

我通过 Circle CI 将我的 Node.Js 应用程序部署到 AWS ECS。

我希望首先运行测试,然后才将图像推送到存储库。但是,目前运行测试的任务与 AWS ECS 任务同时运行。以下是我的./circleci/config.yml 文件。

如何更改此行为,以便仅在测试成功时才推送图像?

version: 2.1
orbs:
  aws-ecr: circleci/aws-ecr@6.10.0
jobs:
  test:
    docker:
      - image: cypress/base:12.18.0
    steps:
      - checkout
      - run: npm ci
      - run: npm run cy:verify
      # save npm dependencies and Cypress binary for future runs
      - save_cache:
          key: cache-{{ checksum "package.json" }}
          paths:
            - ~/.npm
            - ~/.cache
      - run: npm run test:ci

workflows:
  version: 2.1
  test:
    jobs:
      - test
      - aws-ecr/build-and-push-image:
          create-repo: true
          no-output-timeout: 10m
          repo: 'stage-instance'

谢谢!

【问题讨论】:

    标签: docker amazon-ecs circleci circleci-workflows


    【解决方案1】:

    在工作流中添加一个需要步骤以根据条件进行过滤。

    version: 2.1
    orbs:
      aws-ecr: circleci/aws-ecr@6.10.0
    jobs:
      test:
        docker:
          - image: cypress/base:12.18.0
        steps:
          - checkout
          - run: npm ci
          - run: npm run cy:verify
          # save npm dependencies and Cypress binary for future runs
          - save_cache:
              key: cache-{{ checksum "package.json" }}
              paths:
                - ~/.npm
                - ~/.cache
          - run: npm run test:ci
    
    workflows:
      version: 2.1
      test:
        jobs:
          - test
          - aws-ecr/build-and-push-image:
              create-repo: true
              no-output-timeout: 10m
              repo: 'stage-instance'
              requires:
                - test
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-14
      • 2021-07-25
      • 1970-01-01
      • 1970-01-01
      • 2016-04-21
      • 2019-10-08
      • 1970-01-01
      • 2016-05-30
      相关资源
      最近更新 更多