Parallel Builds with S3 artifacts in codebuild - amazon-web-services

I am trying to do batch builds in Codebuild with artifacts enabled. However, I have a strange error as listed below.
no objects found under S3 prefix for dependency artifact pre_build pre_build
This is the buildspec file I am using.
version: 0.2
artifacts:
files:
- '**/*'
batch:
fast-fail: true
build-graph:
- identifier: pre_build
buildspec: ci-cd/application-build/pre_build.yml
ignore-failure: false
- identifier: build_mysql
buildspec: ci-cd/application-build/build_mysql.yml
depend-on:
- pre_build
ignore-failure: false
- identifier: build_rabbitmq
buildspec: ci-cd/application-build/build_rabbitmq.yml
depend-on:
- pre_build
ignore-failure: false
PS: Batch build works with artifacts disabled.
Can someone please suggest me on how to resolve this issue.
My pre_build looks something like this.
Looks something like this.
version: 0.2
phases:
install:
commands:
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2&
- echo This always runs even if the update or install command fails
pre_build:
commands:
- cd ci-cd
- mkdir -p build
- ls
- echo $BUILD_EXPORT_VARIABLE_FILE
- chmod u+x export_github_variables.sh
- . ./export_github_variables.sh
cache:
paths:
- 'ci-cd/build/**/*'

Related

COMMAND_EXECUTION_ERROR AWS CodeBuild

I am trying to setup a s3 bucket and github account to create a pipeline in aws codepipeline service. I am getting an error I can't seem to find. It seems to be related to the NPM Install command, but not sure why. Can someone help please?
COMMAND_EXECUTION_ERROR: Error while executing command: npm i. Reason: exit status 1
BuildSpec:
version: 0.2
env:
variables:
CACHE_CONTROL: "86400"
S3_BUCKET: "{{s3_bucket_url}}"
BUILD_FOLDER: "dist"
phases:
install:
runtime-versions:
nodejs: 16
commands:
- echo Installing source NPM dependencies...
- npm install
- npm install -g #angular/cli
build:
commands:
- echo Build started
- ng build
artifacts:
files:
- '**/*'
base-directory: 'dist*'
discard-paths: yes

AWS CodeDeploy, Files getting removed from other folder

I have a code pipeline setup for React application. Whenever a new build is updated(In client folder) , the files(directories remain) are getting removed the server folder.
Tried seeing the event logs in code deploy, not able to get much info
could someone please help me with this?
appSpec.yml
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/client
hooks:
AfterInstall:
- location: scripts/after.sh
timeout: 300
runas: root
buildSpec.yml
version: 0.2
env:
variables:
NODE_ENV: "development"
phases:
install:
runtime-versions:
nodejs: 14
pre_build:
commands:
- npm install
build:
commands:
- npm run build-qa
artifacts:
type: zip
paths:
- './build/**/*'
- './appspec.yml'
- './scripts/**/*'
after.sh
#!/bin/bash
cd /home/ubuntu/client
echo '---Process started---'
echo '---Taking backup---'
sudo rm -r backup_*
sudo mv /home/ubuntu/client/deploy /home/ubuntu/client/backup_$(date +"%d-%m-%Y")
echo '---backup complete---'
echo '---renaming build---'
sudo mv /home/ubuntu/client/build /home/ubuntu/client/deploy
echo '---renaming complete---'
Edit: I was running two CI/CD pipelines (One for Frontend and other was backend) both running for the same EC2 instance, I was using the same deployment group and application for both the CI/CD which was causing the issue, later I created separate deployment application and group for each CI/CD which resolved . Thanks #Shivkumar Mallesappa for the lead

NextJS with Aws Amplify deployment error

Does anyone has tried AWS-Amplify for next.js deployment? I am getting this error always that "yarn build" successful but didn't deployed and failed.
Git repo is configured with auto-deployment and YML file for aws-amplify is below.
version: 1
frontend:
phases:
preBuild:
commands:
- rm -rf node_modules
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Use this yaml file in your build
version: 1
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: public
files:
- '**/*'
cache:
paths:
- node_modules/**/*

CodeBuild + ReactNative + Expo Web - This build image requires selecting at least one runtime version

Trying to use CodeBuild for the first time, pulling data from CodeCommit. But I'm having issues with my buildspec. This is the code I have on it so far:
version: 0.2
phases:
INSTALL:
runtime-versions:
nodejs: 10
commands:
- npm install
PRE_BUILD:
commands:
- npm install --quiet --global expo-cli
- >
if [ -f yarn.lock ]; then
yarn
elif [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then
npm ci
else
npm install
fi
BUILD:
commands:
- expo build:web
artifacts:
baseDirectory: web-build
files:
- '**/*'
name:
myname-$(date +%Y-%m-%d)
cache:
paths:
- node_modules/**/*
- $(npm root --global)/**/*
I have already added the runtime for nodejs 10, it had stopped to trigger this error, but now it kicked again. Does anyone know how to properly tweak it for React-Native web projects?
I believe the phase names are case sensitive, so change them to install, pre_build and build.

Deploy nuxt on AWS amplify console

I have an aws amplify project built on top of nuxt. I'm trying to setup CI using amplify console. My build keeps failing in deploy stage, for some reason the artifacts aren't being created or can't be found:
Here's my amplify.yml file:
version: 0.1
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- npm install
build:
commands:
- npm run generate
artifacts:
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
If I run npm run generate locally then my app is built and can be found in the dist folder without any problems.
did anyone manage to successfully deploy an amplify/nuxt app using the amplify console?
Thanks
Update 1
change the buildspec:
version: 0.1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run generate
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*