Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket Pipelines Pipe: AWS CodeDeploy

tech71 July 4, 2019

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

 

1 answer

0 votes
Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 4, 2019

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

tech71 July 4, 2019

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 :-

pipeline-error.png

 

Regards,

Venkat

9052325074

Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 5, 2019

@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 .

tech71 July 5, 2019

Hi Alexander Zhukov ,

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,


Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 8, 2019

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'
tech71 July 8, 2019

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?

Capture0.PNGCapture01.PNGCapture02.PNG

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

KuldeepY April 22, 2020

I am getting error 

```
/pipe.sh: line 72: DEPLOYMENT_GROUP: DEPLOYMENT_GROUP variable missing.

```

 

Where do we find the deployment group?

Abryan Manalansang July 18, 2020

@KuldeepY You'll find it in the Repository Settings > Repository Variables.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events