Hi team,
I have setup my bitbucket pipeline using "Bitbucket Pipelines Pipe: AWS CodeDeploy" but I am facing the
error " /pipe.sh: line 40: AWS_ACCESS_KEY_ID: AWS_ACCESS_KEY_ID variable missing.
"
Pipeline Script:-
==============
image: node:10.15.0pipelines:
default:
- step:
name: Build
script:
- "apt-get update -y"
- "cd admin/front-end/"
- "npm install"
- CI=false
- "npm run build"
- "apt-get install -y zip"
- "zip -r /tmp/myapp.zip *"
artifacts:
- myapp.zip
- step:
name: Upload to S3
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: $AKIAS2IMCQIEEY3AQA7Q
AWS_SECRET_ACCESS_KEY: $2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN
COMMAND: 'upload'
APPLICATION_NAME: 'SampleApplication'
ZIP_FILE: 'myapp.zip'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0' - step:
name: Deploy with CodeDeploy
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: $AKIAS2IMCQIEEY3AQA7Q
AWS_SECRET_ACCESS_KEY: $2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN
COMMAND: 'deploy'
APPLICATION_NAME: 'SampleApplication'
DEPLOYMENT_GROUP: 'DG7'
WAIT: 'true'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'
Can any one please help me in this issue ASAP.
I have followed the following link:-
https://confluence.atlassian.com/bitbucket/deploy-to-amazon-aws-875304040.html
and
https://hackernoon.com/deploy-to-ec2-with-aws-codedeploy-from-bitbucket-pipelines-4f403e96d50c
Regards,
Venkat
Hi @tech71 . You have a dollar sign in front of your keys. The pipe thinks that it's a reference to the environment variable. Removing the dollar sign will solve the issue. However, it's better to not hard code your keys in the bitbucket_pipelines.yml and user Pipelines variables to store them. Hope that helps
Hi Alexander Zhukov ,
Thanks for your reply, I tried without dollar sign in my script but i am getting following error can you please check and reply with solution and I have attached my scripts and screenshot of my error.
Pipeline Script:-
image: node:10.15.0
pipelines:
default:
- step:
name: Build
script:
- "apt-get update -y"
- "cd admin/front-end/"
- "npm install"
- CI=false
- "npm run build"
- "apt-get install -y zip"
- "zip -r /tmp/myapp.zip *"
artifacts:
- myapp.zip
- step:
name: Upload to S3
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'upload'
APPLICATION_NAME: 'SampleApplication'
ZIP_FILE: 'myapp.zip'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'
- step:
name: Deploy with CodeDeploy
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'deploy'
APPLICATION_NAME: 'SampleApplication'
DEPLOYMENT_GROUP: 'DG7'
WAIT: 'true'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'
========================================
Error :-
Regards,
Venkat
9052325074
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@tech71 , in your "Build" step you create a zip archive under the /tmp directory. However, artifacts paths are relative to the current working directory. You should instead create a zip file in the current working directory
zip -r myapp.zip *
After that your myapp.zip will be available as an artifact for next steps. For more details you can refer to the docs for using artifacts .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your quick reply and As per your instruction I have changed the "zip -r myapp.zip *" but I am getting same error .
Please edit my code and reply back if possible .
Pipeline:-
image: node:10.15.0
pipelines:
default:
- step:
name: Build
script:
- apt-get update -y
- cd admin/front-end/
- npm install
- CI=false
- npm run build
- apt-get install -y zip
- zip -r myapp.zip *
artifacts:
- myapp.zip
- step:
name: Upload to S3
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'upload'
APPLICATION_NAME: 'SampleApplication'
ZIP_FILE: 'myapp.zip'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'
- step:
name: Deploy with CodeDeploy
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'deploy'
APPLICATION_NAME: 'SampleApplication'
DEPLOYMENT_GROUP: 'DG7'
WAIT: 'true'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'
Thanks and Regards,
Venkat,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @tech71 . Since your building your app under the admin/front-end/ directory, your artifact will be stored under that directory, so you need to change your artifacts path:
artifacts:
- admin/front-end/myapp.zip
You should also change the path to ZIP_FILE as well:
ZIP_FILE: 'admin/front-end/myapp.zip'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexander Zhukov ,
Thanks for your quick reply , Actually earlier I was using AWS code deploy Plugin, where as it was working and i had two paths for deployment, one was for fron-end second was for back;-end. Now I am using this scripted pipeline as there AWS code deploy Plugin removed form Market-place-bit bucket side.
Now the now artifact is going to S3, but deployment is failed, my deployment path is /var/www/html.
but in script I didn't find any variables into it.
Can you please help me with this?
Pipeline Script:-
image: node:10.15.0
pipelines:
default:
- step:
name: Build
script:
- apt-get update -y
- cd admin/front-end/
- npm install
- CI=false
- npm run build
- apt-get install -y zip
- zip -r myapp.zip *
artifacts:
- admin/front-end/myapp.zip
- step:
name: Upload to S3
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'upload'
APPLICATION_NAME: 'SampleApplication'
ZIP_FILE: 'admin/front-end/myapp.zip'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'
- step:
name: Deploy with CodeDeploy
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'deploy'
APPLICATION_NAME: 'SampleApplication'
DEPLOYMENT_GROUP: 'DG7'
WAIT: 'true'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'
Thank you
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.