CircleCi 2.0:找不到aws命令

时间:2018-09-03 04:48:59

标签: amazon-web-services circleci migrate

我尝试将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:找不到命令”。我不确定是否做错了什么,但是我想知道问题出在哪里以及如何解决。谢谢。

3 个答案:

答案 0 :(得分:2)

我会重新配置您的配置。每个工作都应有重点/重点。例如,对于部署,您不需要NodeJS,您需要AWS CLI,因此可以使用映像。

using System;
using System.Collections.Generic;
using System.Device.Location;
using System.Globalization;
using System.Linq;
using WebService.Models.Domain;
using Microsoft.AspNet.SignalR;

namespace WebService
{
    public class MyHub : Hub
    {
        private readonly mydb db = new mydb();

        public void Send(string storeToken)
        {
            try
            {
                if (storeToken != null)
                {
                    ......
                    ......
                    ......

                                if (distanceInMeter < maxStoreDistance)
                                {
                                    var obj = new GetBuy
                                    {
                                        buy = new AllBuy
                                        {
                                            id = newBuyRequest.Id,
                                            longitude = newBuyRequest.longitude ?? 0,
                                            latitude = newBuyRequest.latitude ?? 0,
                                            time = Convert.ToString(newBuyRequest.time, CultureInfo.InvariantCulture),
                                            price = newBuyRequest.price ?? 0,
                                            distanceInMeter = distanceInMeter
                                        }
                                    };

                                    resultList.Add(obj.buy);
                                }



                        Clients.All.sendToShop(resultList);
                    }
                }

                Clients.All.sendToShop("error");
            }
            catch (Exception)
            {
                Clients.All.sendToShop("error");
            }
        }

        //************************************
        private class GetBuy
        {
            public AllBuy buy;
        }
        private class AllBuy
        {
            public int id;
            public double longitude;
            public double latitude;
            public string time;
            public double price;
            public double distanceInMeter;
        }
    }
}

答案 1 :(得分:0)

尝试以下步骤(摘自其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

答案 2 :(得分:0)

这种用于安装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