code deployment failed

harjeet97 January 9, 2020

Bitbucket pipeline failed due to code deploy on aws. 

pythen code_deploy.py error

1 comment

Minh Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 9, 2020

What exact problem have you met @harjeet97? Any exception or any thing that you can share?

harjeet97 January 9, 2020

Thanks for response @Minh Tran 

I am deploying code from bitbucket to aws and getting issue in deploying the code.

Pelase find the attached screenshotq.pngScreenshot from 2020-01-10 09-43-39.png

I am using bitbucket-pipeline.yml.

here is the code :

# This is a sample build configuration for PHP.# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.# Only use spaces to indent your .yml configuration.# -----# You can specify a custom docker image from Docker Hub as your build environment.image: php:7.2.5pipelines: default: - step: caches: - composer script: - printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list - apt-get update && apt-get install -y unzip python-dev git - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - curl -O https://bootstrap.pypa.io/get-pip.py - python get-pip.py - cd ./src - composer install branches: dev-release: - step: caches: - composer script: - printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list - apt-get update && apt-get install -y unzip python-dev git - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - curl -O https://bootstrap.pypa.io/get-pip.py - python get-pip.py - cd ./src - composer --version #- composer global require "fxp/composer-asset-plugin:^1.2.0" - composer install - cp ./environments/dev/frontend/web/index.php ./frontend/web/index.php - cp ./environments/dev/backend/web/index.php ./backend/web/index.php - cd ../ # Packing - tar -cvf publish.tar -C ./src .
# Upload to s3 - pip install boto3==1.3.0 - python bitbucket-s3-upload.py "autobank-opt-cd-dev-server" publish.tar "${BITBUCKET_COMMIT}.tar" - python bitbucket-s3-upload.py "autobank-opt-cd-dev-server" publish.tar "latest.tar" - step: name: Deploy to Dev/UAT image: python:3.5.1 deployment: test script: - printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list - apt-get update # required to install zip - apt-get install -y zip # required for packaging up the application - pip install boto3==1.3.0 # required for codedeploy_deploy.py #- zip -r /tmp/artifact.zip * # package up the application for deployment - python codedeploy_deploy.py # run the deployment script
# rrr

prod-release: - step: caches: - composer script: - printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list - apt-get update && apt-get install -y unzip python-dev git - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - curl -O https://bootstrap.pypa.io/get-pip.py - python get-pip.py - cd ./src - composer --version #- composer global require "fxp/composer-asset-plugin:^1.2.0" - composer install - cp ./environments/prod/frontend/web/index.php ./frontend/web/index.php - cp ./environments/prod/backend/web/index.php ./backend/web/index.php - cd ../ # Packing - tar -cvf publish.tar -C ./src .
# Upload to s3 - pip install boto3==1.3.0 - python bitbucket-s3-upload.py "autobank-opt-cd-prod-server" publish.tar "${BITBUCKET_COMMIT}.tar" - python bitbucket-s3-upload.py "autobank-opt-cd-prod-server" publish.tar "latest.tar" - step: name: Deploy to Prod/Staging image: python:3.5.1 deployment: production trigger: manual script: - printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list - apt-get update # required to install zip - apt-get install -y zip # required for packaging up the application - pip install boto3==1.3.0 # required for codedeploy_deploy.py # - zip -r /tmp/artifact.zip * # package up the application for deployment - python codedeploy_deploy_prod.py # run the deployment script

 

 

Can you please help me to resolve this error.

Thanks in advance @Minh Tran 

Minh Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 9, 2020

Does your python codedeploy_deploy_prod.py work outside pipeline @harjeet97 

harjeet97 January 9, 2020

yes @Minh

it is for production environment.

I am deploying on DEV environment right now.

Minh Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 9, 2020

Yes, try it with your script first. There might be something like AWS token value for different environments that should be taken carefully too

harjeet97 January 9, 2020

First script?

 

Which one?

Actually it works correctly and i suddenly got this error.

Minh Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 10, 2020

The one with the dev environment

harjeet97 January 10, 2020

Okay.. I will try with first script.

Can you please let me know.. Is bitbucket- pipeline.yml file changes effected the code_deploy.py file.

 

I changed the docker image PHP version in 7.2.5 from 7.1.3. I am not sure it happens due to this change or not.

I changed PHP version because I got error to upgrade version.

Minh Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 11, 2020

Is bitbucket- pipeline.yml file changes effected the code_deploy.py file.

It is hard to say if that is truly reason. In my own experience, i will depend on the error / the log or any trace that will show us when the script failed

That will be a big thing to lead us to root cause

harjeet97 January 11, 2020

this is the log error @Minh Tran 

 

i found under var/log/aws/code-deploy-agent.log

Checking first if any deployment lifecycle event is in progress master 0

harjeet97 January 11, 2020

can you let me know "AWS_DEFAULT_REGION" may be the issue or not.

AWS_DEFAULT_REGION = ap-southeast-2

I am running it from india? I am not sure about it so just asking it may be the issue or not?

Minh Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 13, 2020

I don't think the region may contribute to the problem here

Can you share the content of /var/log/aws/code-deploy-agent.log ?

harjeet97 January 13, 2020

2020-01-13 00:00:47 INFO [codedeploy-agent(1406)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.0-1.1597_deb.
2020-01-13 00:01:47 INFO [codedeploy-agent(1406)]: [Aws::CodeDeployCommand::Client 200 60.055356 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:ap-southeast-2:730515994015:instance/i-04e50fcaf6a334635")

2020-01-13 00:01:48 INFO [codedeploy-agent(1406)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.0-1.1597_deb.
2020-01-13 00:02:49 INFO [codedeploy-agent(1406)]: [Aws::CodeDeployCommand::Client 200 60.851167 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:ap-southeast-2:730515994015:instance/i-04e50fcaf6a334635")

2020-01-13 00:02:50 INFO [codedeploy-agent(1406)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.0-1.1597_deb.
2020-01-13 00:03:51 INFO [codedeploy-agent(1406)]: [Aws::CodeDeployCommand::Client 200 60.55788 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:ap-southeast-2:730515994015:instance/i-04e50fcaf6a334635")

2020-01-13 00:03:52 INFO [codedeploy-agent(1406)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.0-1.1597_deb.
2020-01-13 00:04:53 INFO [codedeploy-agent(1406)]: [Aws::CodeDeployCommand::Client 200 60.99522 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:ap-southeast-2:730515994015:instance/i-04e50fcaf6a334635")

2020-01-13 00:04:54 INFO [codedeploy-agent(1406)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.0-1.1597_deb.
2020-01-13 00:05:55 INFO [codedeploy-agent(1406)]: [Aws::CodeDeployCommand::Client 200 60.910334 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:ap-southeast-2:730515994015:instance/i-04e50fcaf6a334635")

2020-01-13 00:05:56 INFO [codedeploy-agent(1406)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.0-1.1597_deb.
2020-01-13 00:06:57 INFO [codedeploy-agent(1406)]: [Aws::CodeDeployCommand::Client 200 60.916952 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:ap-southeast-2:730515994015:instance/i-04e50fcaf6a334635")

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events