Maciej
Maciej

Reputation: 1499

AWS CodePipeline - artifact file permission denied

Have and issue with yaml / json and error like below. Didn't change lines responsible for producing artifacts in AWS CodePipeline yet it throws error like below...

[Container] 2020/07/30 17:18:27 Running command printf '[{"name":"production-celery","imageUri":"%s"}]' $CELERY_REPO_URI:$IMAGE_TAG > build/codebuild/imagedefinitions-prod-celery.json || true
   

[Container] 2020/07/30 17:18:27 Running command ls -la build/codebuild/
   
total 36
   
drwxr-xr-x 2 root root 4096 Jul 30 17:18 .
    
drwxr-xr-x 5 root root 4096 Jul 30 17:16 ..
    
-rw-rw-r-- 1 root root 2569 Jul 30 17:06 Buildspec_production.yml
    
-rw-rw-r-- 1 root root 1157 Jul 30 17:06 Buildspec_staging.yml

-rw-rw-r-- 1 root root  351 Jul 30 17:06 buildspec_ci.yml
   
-rw-rw-r-- 1 root root  351 Jul 30 17:06 buildspec_prod_ci.yml
   
-rw-r--r-- 1 root root  110 Jul 30 17:18 imagedefinitions-prod-app.json
    
-rw-r--r-- 1 root root  108 Jul 30 17:18 imagedefinitions-prod-celery.json



-rw-rw-r-- 1 root root  580 Jul 30 17:06 imagedefinitions-staging.json

    
[Container] 2020/07/30 17:18:27 Running command cat build/codebuild/imagedefinitions-prod-celery.json

[{"name":"production-celery","imageUri":"xxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/celery-repo:7fb56ff"}]
    
[Container] 2020/07/30 17:18:27 Running command build/codebuild/imagedefinitions-prod-celery.json   
/codebuild/output/tmp/script.sh: 4: /codebuild/output/tmp/script.sh: build/codebuild/imagedefinitions-prod-celery.json: Permission denied
  
[Container] 2020/07/30 17:18:27 Command did not exit successfully build/codebuild/imagedefinitions-prod-celery.json exit status 126

[Container] 2020/07/30 17:18:27 Phase complete: POST_BUILD State: FAILED
   
[Container] 2020/07/30 17:18:27 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: build/codebuild/imagedefinitions-prod-celery.json. Reason: exit status 126

Have no idea what is wrong and why it throws Permission denied ??? Anyone did encounter such error?

EDIT: yesterday evening was working fine... no changes...

Upvotes: 0

Views: 3463

Answers (2)

Carlos Gomez
Carlos Gomez

Reputation: 230

for others cases, where the reason would be permissions you can add explicit privileges to the file that you want execute (E.g. task.sh). This work for me. Example:

 chmod +x task.sh

Upvotes: 1

shariqmaws
shariqmaws

Reputation: 8890

Running command build/codebuild/imagedefinitions-prod-celery.json 

This seems like an invalid command:

build/codebuild/imagedefinitions-prod-celery.json 

If a command is found but is not executable, the return status is 126.

Please check your command in buildspec.

Upvotes: 2

Related Questions