Serverless deploy with plugins and dockerpip
Asked by Aakash Shah:

I am unable to figure out why the serverless deploy is not going through.

This is the bibucket-pipeline.yml



    options:
    docker: true

    definitions:
     services:
     docker:
     memory: 3072
    pipelines:
    branches:

    dev:
     - step:
    services:
     - docker
    script:
     - cp config.dev.ini config.ini
     - pipe: atlassian/serverless-deploy:1.2.0
    variables:
     AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID_DEV
     AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY_DEV
     PRE_EXECUTION_SCRIPT: "my-script.sh"
     EXTRA_ARGS: "--verbose"

`Error during serverless deploy`

    Installing requirements from "/root/.cache/serverless-python-requirements/1f8875b144ca0ef6448bc54adcda2143dac724167f52c31feeb3279ccc4a6bc1_x86_64_slspyc/requirements.txt"
    Docker Image: lambci/lambda:build-python3.8
    Using download cache directory /root/.cache/serverless-python-requirements/downloadCacheslspyc
    Running docker run --rm -v /root/.cache/serverless-python-requirements/1f8875b144ca0ef6448bc54adcda2143dac724167f52c31feeb3279ccc4a6bc1_x86_64_slspyc\:/var/task\:z -v /root/.cache/serverless-python-requirements/downloadCacheslspyc\:/var/useDownloadCache\:z lambci/lambda\:build-python3.8 /bin/sh -c 'chown -R 0\\:0 /var/useDownloadCache && python3 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache && chown -R 0\\:0 /var/task && chown -R 0\\:0 /var/useDownloadCache && find /var/task -name \\*.so -exec strip \\{\\} \\;'...
    Stdout: 
    Stderr: docker: Error response from daemon: authorization denied by plugin pipelines: -v only supports $BITBUCKET_CLONE_DIR and its subdirectories.
    See 'docker run --help'.
    Environment: linux, node 16.17.0, framework 3.22.0 (local) 3.22.0v (global), plugin 6.2.2, SDK 4.3.2

    Credentials: Local, environment variables

    Docs:        http://docs.serverless.com/

    Support:     http://forum.serverless.com/

    Bugs:        http://github.com/serverless/serverless/issues


    Error:

    Error: `docker run --rm -v /root/.cache/serverless-python-requirements/1f8875b144ca0ef6448bc54adcda2143dac724167f52c31feeb3279ccc4a6bc1_x86_64_slspyc:/var/task:z -v /root/.cache/serverless-python-requirements/downloadCacheslspyc:/var/useDownloadCache:z lambci/lambda:build-python3.8 /bin/sh -c chown -R 0\:0 /var/useDownloadCache && python3 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache && chown -R 0\:0 /var/task && chown -R 0\:0 /var/useDownloadCache && find /var/task -name \*.so -exec strip \{\} \;` Exited with code 125

        at ChildProcess.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/child-process-ext/spawn.js:38:8)

        at ChildProcess.emit (node:events:513:28)

        at ChildProcess.emit (node:domain:489:12)

        at maybeClose (node:internal/child_process:1093:16)

        at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

serverless.yml  

```
custom:

pythonRequirements:

pythonBin: python3

dockerizePip: true

slim: true

useDownloadCache: true

useStaticCache: true
```

Any help would be very much appreciated. It loks like its because of useDownloadCache or this could be it - $BITBUCKET_CLONE_DIR and its subdirectories.


Answers:
author: Igor Stoyanov
body: [@Aakash Shah](/t5/user/viewprofilepage/user-id/5027570) hi. Could your share also your pre-execution script?

Regards, Igor


author: Syahrul
body: Hey [@Aakash Shah](/t5/user/viewprofilepage/user-id/5027570)

Welcome to the community.

I believe the error is related to the execution permission of the script. As mentioned in the documentation [here](https://bitbucket.org/atlassian/serverless-deploy/src/master/) if you pass a hook script, the script should have at least read and execution permission.

I would suggest changing the script permission with the following step:

```
  - chmod 005 my-script.sh  - pipe: atlassian/serverless-deploy:1.2.0    variables:      AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID      AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY      PRE_EXECUTION_SCRIPT: '.my-script.sh'
```

Cheers,  
Syahrul


Tags: bitbucket-cloud

cloud

lambda