CircleCI报告mkdir成功,但是找不到目录

时间:2019-09-22 21:05:58

标签: ubuntu circleci amazon-linux

新的CircleCI用户在这里。我一直在努力执行mkdir命令。或者,更准确地说,是找到命令执行的结果

该步骤在我的工作流程中成功退出,但是该文件夹似乎并不存在。我无法在文件系统中的任何位置找到它。

这是我的config.yml文件:

# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
  build:
    branches:
      only:
        - staging
    working_directory: ~/build
    docker:
      - image: circleci/php:7.2-node-browsers

    steps:
      - checkout

      - run: 
          name: APT Installs (ZIP, PDO, MySQL, Composer)
          command: |        
            sudo docker-php-ext-install zip
            sudo docker-php-ext-install pdo pdo_mysql
            sudo apt-get install software-properties-common
            sudo composer self-update

      - run: 
          name: Install Python and PIP
          command: |
            sudo apt-get install -y python3.7
            sudo apt install -y python3-pip
            sudo pip3 install --upgrade pip
            sudo pip3 install --upgrade awscli
            sudo pip3 install --upgrade awsebcli

      - run:
          name: Create Image Directory (if not exists)
          command: |            
            sudo mkdir -m 0755 -p /var/user_image
            ls -l /var/user_image

      - run:
          name: Setup AWS credentials
          command: |
            mkdir ~/.aws && printf "[profile eb-cli]\naws_access_key_id = $REDACTED\naws_secret_access_key = $REDACTED" > ~/.aws/config

      - deploy:
          name: Deploy to Elastic Beanstalk
          command: |
            eb deploy PixapadTest-env

      # Download and cache dependencies
      - restore_cache:
          keys:
            # "composer.lock" can be used if it is committed to the repo
            - v1-dependencies-{{ checksum "composer.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-      

      - restore_cache:
          keys:
            - node-v1-{{ checksum "package.json" }}
            - node-v1-

      - run: 
          name: Install app dependencies
          command: |       
            composer install -n --prefer-dist

      - save_cache:
          key: v1-dependencies-{{ checksum "composer.json" }}
          paths:
            - ./vendor

      - run:
          name: Database Setup
          command: |
            vendor/bin/phinx migrate -e staging

这是最近成功的工作流程的屏幕截图:

enter image description here

我要去哪里错了?

编辑#1::在CircleCI用户的建议下,我在ls -l /var/user_image下方的config.yml中添加了sudo mkdir -m 0755 -p /var/user_image。工作流程步骤输出以下内容:

enter image description here

没有错误,但是我仍然找不到目录。我怀疑这时它正在被某个进程删除...我只是不确定为什么。

编辑#2:已更新为完整config.yml。

1 个答案:

答案 0 :(得分:0)

最后,我使这个复杂化,并且误解了该过程。

我的目标是在我的应用程序服务器上创建一个目录,该目录托管在Elastic Beanstalk中。尽管我想在服务器上创建目录,但是我在config.yml文件中使用的命令正在容器中创建目录。 CircleCI表现完美。我没有!

相反,我只需要将命令添加到.ebextensions源文件夹中的配置文件中即可。

这是.ebextensions文件夹中的完整配置文件,适用于运行此文件的其他任何人。

files:
    "/root/.ssh/config":
        owner: root
        group: root
        mode: "000600"
        content: |
            Host github.com
                User git
                Hostname github.com
                IdentityFile /root/.ssh/battlestardigitalbot-github-deploy
    "/root/.ssh/known_hosts":
        owner: root
        group: root
        mode: "000644"
        content: |
            [REDACTED]


commands:
    01-command:
        command: sudo aws s3 cp s3://battlestar-deployment-key/battlestardigitalbot-github-deploy /root/.ssh
    02-command:
        command: sudo chmod 600 /root/.ssh/battlestardigitalbot-github-deploy
    03-command:
        command: sudo mkdir -m 0755 -p /var/user_image

特别感谢FelicianoTech,他的耐心询问最终使我的点点头误了!