CircleCi 2.0:找不到aws命令

问题描述 投票:0回答:3

我尝试将circleci从v1.0迁移到v2.0。

首先,我无法安装awscli,但最终可以使用下面的代码安装它,但得到另一个无法找到aws命令的错误。

version: 2
    jobs:
      build:
        docker:
          - image: circleci/node:8.9.1
    steps:
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
  - save_cache:
      key: dependency-cache-{{ checksum "package.json" }}
      paths:
        - node_modules
deploy:
    docker:
      - image: circleci/node:8.9.1
steps:
  - checkout
  - run:
      name: Install yarn
      command: yarn install
  - run:
      name: Install awscli
      command: |
        sudo apt-get install python-pip python-dev
        pip install 'pyyaml<4,>=3.10' awscli --upgrade --user
  - run:
      name: AWS S3
      command: aws s3 sync build s3://<URL> --delete

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

它显示“aws:command not found”。我不确定我做错了什么但是我想知道问题是什么以及如何解决它。谢谢。

amazon-web-services circleci migrate
3个回答
2
投票

我会修改你的配置。每个工作都应该有一个焦点/点。例如,对于部署,您不需要NodeJS,您需要AWS CLI,因此请使用图像。

version: 2
    jobs:
      build:
        docker:
          - image: circleci/node:8.9.1
    steps:
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
  - save_cache:
      key: dependency-cache-{{ checksum "package.json" }}
      paths:
        - node_modules
  - persist_to_workspace:
      root: /home/circleci
      paths: project
deploy:
    docker:
      - image: cibuilds/aws:1.16.1
steps:
  - checkout
  - attach_workspace:
      at: /home/circleci
  - run:
      name: AWS S3
      command: aws s3 sync build s3://<URL> --delete

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

1
投票

尝试使用以下步骤(取自他们的v2文档);

steps:
  - run:
      name: Install PIP
      command: sudo apt-get install python-pip python-dev
  - run:
      name: Install awscli
      command: sudo pip install awscli
  - run:
      name: Deploy to S3
      command: aws s3 sync build s3://<URL> --delete

1
投票

这种安装awscli的方法似乎在各种系统上都能正常工作。测试circleci / openjdk:8-jdk,无需额外安装。

编辑似乎节点映像缺少libpython-dev的安装。

##################
# Install AWS CLI
##################

# For node images on Circle, install libpython-dev
sudo apt-get install -y libpython-dev

# Download awscli bundle
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"

# Unzip the downloaded bundle
unzip awscli-bundle.zip

# Run the install script and install to ~/bin/aws directory
./awscli-bundle/install -b ~/bin/aws

之后,要运行awscli命令,请指定aws可执行文件的完整路径,例如:

~/bin/aws s3 ls

资源

Helpful thread GitHub

Example GitHub repository with Circle config on node:8.9.1

The CircleCI builds

© www.soinside.com 2019 - 2024. All rights reserved.