- "BuildSpec": "{\n \"version\": \"0.2\",\n \"phases\": {\n \"install\": {\n \"runtime-versions\": {\n \"nodejs\": 18\n }\n },\n \"build\": {\n \"commands\": [\n \"current_dir=$(pwd)\",\n \"\\nfor obj in $(echo \\\"$input\\\" | jq -c '.[]'); do\\n assetUrl=$(echo \\\"$obj\\\" | jq -r '.assetUrl')\\n extractPath=$(echo \\\"$obj\\\" | jq -r '.extractPath')\\n commands=$(echo \\\"$obj\\\" | jq -r '.commands')\\n\\n # Download the zip file\\n aws s3 cp \\\"$assetUrl\\\" temp.zip\\n\\n # Extract the zip file to the extractPath directory\\n mkdir -p \\\"$extractPath\\\"\\n unzip temp.zip -d \\\"$extractPath\\\"\\n\\n # Remove the zip file\\n rm temp.zip\\n\\n # Run the specified commands in the extractPath directory\\n cd \\\"$extractPath\\\"\\n ls -la\\n eval \\\"$commands\\\"\\n cd \\\"$current_dir\\\"\\n ls -la\\ndone\\n \",\n \"ls -la\",\n \"cd \\\"$workingDirectory\\\"\",\n \"eval \\\"$buildCommands\\\"\",\n \"ls -la\",\n \"cd \\\"$current_dir\\\"\",\n \"cd \\\"$outputSourceDirectory\\\"\",\n \"zip -r output.zip ./\",\n \"aws s3 cp output.zip \\\"s3://$destinationBucketName/$destinationObjectKey\\\"\"\n ]\n },\n \"post_build\": {\n \"commands\": [\n \"echo Build completed on `date`\",\n \"\\nSTATUS='SUCCESS'\\nif [ $CODEBUILD_BUILD_SUCCEEDING -ne 1 ] # Test if the build is failing\\nthen\\nSTATUS='FAILED'\\nREASON=\\\"NodejsBuild failed. See CloudWatch Log stream for the detailed reason: \\nhttps://$AWS_REGION.console.aws.amazon.com/cloudwatch/home?region=$AWS_REGION#logsV2:log-groups/log-group/\\\\$252Faws\\\\$252Fcodebuild\\\\$252F$projectName/log-events/$CODEBUILD_LOG_PATH\\\"\\nfi\\ncat <<EOF > payload.json\\n{\\n \\\"StackId\\\": \\\"$stackId\\\",\\n \\\"RequestId\\\": \\\"$requestId\\\",\\n \\\"LogicalResourceId\\\":\\\"$logicalResourceId\\\",\\n \\\"PhysicalResourceId\\\": \\\"$destinationObjectKey\\\",\\n \\\"Status\\\": \\\"$STATUS\\\",\\n \\\"Reason\\\": \\\"$REASON\\\"\\n}\\nEOF\\ncurl -vv -i -X PUT -H 'Content-Type:' -d \\\"@payload.json\\\" \\\"$responseURL\\\"\\n \"\n ]\n }\n }\n}",
0 commit comments