CircleCI 报告 mkdir 成功,但找不到目录
CircleCI reports mkdir successful, but can't find directory
这里是新的 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
这是最近成功的工作流程的屏幕截图:
我哪里错了?
编辑 #1: 根据 CircleCI 用户的建议,我将 ls -l /var/user_image
添加到 sudo mkdir -m 0755 -p /var/user_image
下方的 config.yml。工作流步骤输出以下内容:
没有错误,但还是找不到目录。我怀疑此时它正在被进程删除...我只是不确定为什么。
编辑 #2: 更新完整 config.yml.
最后,我把这个复杂化了,误解了这个过程。
我的目标是在我的应用程序服务器上创建一个目录,该目录托管在 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,他们耐心的问题最终让我的头脑清醒过来!
这里是新的 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
这是最近成功的工作流程的屏幕截图:
我哪里错了?
编辑 #1: 根据 CircleCI 用户的建议,我将 ls -l /var/user_image
添加到 sudo mkdir -m 0755 -p /var/user_image
下方的 config.yml。工作流步骤输出以下内容:
没有错误,但还是找不到目录。我怀疑此时它正在被进程删除...我只是不确定为什么。
编辑 #2: 更新完整 config.yml.
最后,我把这个复杂化了,误解了这个过程。
我的目标是在我的应用程序服务器上创建一个目录,该目录托管在 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,他们耐心的问题最终让我的头脑清醒过来!