PRE_EXECUTION_SCRIPT hangs for serverless_deploy:1.4.0

osep_redmine September 27, 2023

Following the example in the serverless-deploy documentation, I've added the following code to my pipeline:

- echo 'npm install serverless-lift@1.*' > .install-sls-plugins.sh
# - echo 'cat serverless.yml && echo "Youre grounded"' > .install-sls-plugins.sh
- chmod +x .install-sls-plugins.sh
- pipe: atlassian/serverless-deploy:1.4.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
DEBUG: 'true'
EXTRA_ARGS: '--stage ${STAGE}'
PRE_EXECUTION_SCRIPT: '.install-sls-plugins.sh'

 

When `.install-sls-plugins.sh` tries to run an npm command the pipe hangs and eventually times out ater 10 minutes with the following message:

INFO: Executing pre-execution script before pipe running sh .install-sls-plugins.sh
time="2023-09-27T15:50:09Z" level=error msg="error waiting for container: unexpected EOF"

When I change the contents of the script to `cat` and `echo` (as seen in the commented-out line above) the script runs fine, but the pipe fails because the lift plugin is missing, even though it's listed as a dependency in the `serverless.yml` file.

I'd like to avoid having to compile my own pipe, and this seems like exactly what the pre-execution script is designed for, based on the docs. How can I solve this?

1 answer

0 votes
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2023

Hi @osep_redmine 

Thank you for your question!

To try to solve your issue you could create a file with pre-executions logic inside

.install-sls-plugins.sh

instead of feed it on-fly with echo command, because it depends on shell that you use in the step.

and try to set permissions explicitly

- chmod 755 .install-sls-plugins.sh


Best regards,
Oleksandr Kyrdan

osep_redmine September 29, 2023

@Oleksandr Kyrdan 

This was, indeed, an improvement, if only in terms of error reporting. I added the file install-sls-plugins.sh to my repo with the following contents:

# /bin/bash

npm install serverless-lift@1.*

And I edited bitbucket-pipelines.yml to look like the following:

- pipe: atlassian/serverless-deploy:1.4.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
DEBUG: 'true'
EXTRA_ARGS: '--stage ${STAGE}'
PRE_EXECUTION_SCRIPT: 'install-sls-plugins.sh'

 

But while the script appears to have permission to run, I cannot actually install any new Serverless plugins via npm install, based on the errors as seen below:

INFO: Executing pre-execution script before pipe running sh install-sls-plugins.sh
* npm ERR! code EACCES 
npm ERR! syscall mkdir
npm ERR! path /opt/atlassian/pipelines/agent/build/node_modules/fsevents
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/opt/atlassian/pipelines/agent/build/node_modules/fsevents'
npm ERR! [Error: EACCES: permission denied, mkdir '/opt/atlassian/pipelines/agent/build/node_modules/fsevents'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/opt/atlassian/pipelines/agent/build/node_modules/fsevents'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-09-29T16_43_41_220Z-debug-0.log

Like Sabine Mayer likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events