我有config.yaml
尝试将代码上传到AWS。在第一个版本中,它可以正常工作,但现在不起作用。我该如何解决?我添加了deploy
部分并编写了sh命令
version: 2
jobs:
build:
working_directory: ~/myProject
parallelism: 1
shell: /bin/bash --login
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
docker:
- image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37
command: /sbin/init
steps:
- checkout
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
- run:
working_directory: ~/myProject
command: nvm install 8.9.1 && nvm alias default 8.9.1
- restore_cache:
keys:
- v1-dep-{{ .Branch }}-
- v1-dep-master-
- v1-dep-
- run: sudo sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
- run: sudo apt update
- run: sudo apt-get install python2.7-dev
- run: sudo easy_install --upgrade six
- run: sudo pip install --upgrade urllib3==1.21.1
- run: sudo pip install --upgrade pip
- run: sudo pip install --upgrade blessed
- run: sudo pip install awsebcli==3.12.3 --ignore-installed six pyyaml
- run: rm -rf /home/ubuntu/.aws
- run: if [ -z "${NODE_ENV:-}" ]; then export NODE_ENV=test; fi
- run: export PATH="~/myProject/node_modules/.bin:$PATH"
- run: npm install
- save_cache:
key: v1-dep-{{ .Branch }}-{{ epoch }}
paths:
- vendor/bundle
- ~/virtualenvs
- ~/.m2
- ~/.ivy2
- ~/.bundle
- ~/.go_workspace
- ~/.gradle
- ~/.cache/bower
- ./node_modules
- run: npm test
- store_test_results:
path: /tmp/circleci-test-results
- store_artifacts:
path: /tmp/circleci-artifacts
- store_artifacts:
path: /tmp/circleci-test-results
deploy:
name: deploy to AWS
production:
branch: production
commands:
- bash ./deploy_prod.sh
- eb deploy stmi-production
staging:
branch: master
commands:
- bash ./deploy_staging.sh
- eb deploy stmi-dev
答案 0 :(得分:0)
这对我有用:
machine: true
steps:
- checkout
- run:
name: create workspace
command: mkdir -p /tmp/workspace
- run:
name: Install awsebcli package
command: |
sudo apt-get -y -qq update
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade awsebcli
eb --version
- run:
name: installing dependencies
command: |
npm install
- run:
name: deploy
command: |
bash deploy.sh
- run:
name: Removing aws config
command: |
rm -rf /home/circleci/.aws
- run: ls /tmp/workspace
- persist_to_workspace:
root: /tmp/workspace
paths:
- status.txt`
这是我的deploy.sh
mkdir /home/circleci/.aws
touch /home/circleci/.aws/config
chmod 600 /home/circleci/.aws/config
echo "[profile user]" > /home/circleci/.aws/config
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> /home/circleci/.aws/config
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >>
/home/circleci/.aws/config
eb deploy $BEANSTALK_ENVIRONMENT --profile user --region
$BEANSTALK_PRODUCTION_AWS_REGION &&
echo 'Deployment Succeed' >> /tmp/workspace/beanstalk-deploy-
status.txt