Skip to content

EC2 Configuration: Serverless Build Fail

0

Hi,

I have set up an EC2 instance that is meant to run Jenkins jobs. It has Serverless Framework 2.75 installed along with python 3.12.11. However, when I git commit my project, the pipeline is failing with the following error:

Execution failed for task ':publishServerless'.

A problem occurred starting process 'command 'serverless''

I am not sure why Jenkins is not able to discover serverless.yaml in the EC2.

I hope you can help.

1 Answer
0

Based on the error you're experiencing with your Jenkins pipeline on EC2, there are several potential causes for the "Execution failed for task ':publishServerless'" error:

  1. Path Configuration Issues: Jenkins might not be able to find the Serverless Framework executable in the system path. When Jenkins runs as a service, it may have a different PATH environment variable than your user account.

  2. Permission Problems: The Jenkins user might not have sufficient permissions to execute the serverless command or access the necessary files.

  3. Installation Scope: Serverless Framework might be installed for your user account only, not globally on the system where Jenkins can access it.

Here are some troubleshooting steps you can take:

  1. Verify Serverless Installation: Make sure Serverless is installed globally (for example, via npm):
npm install -g serverless
  1. Use Absolute Paths: In your Jenkins pipeline, try using the absolute path to the serverless executable instead of relying on PATH.

  2. Check Jenkins Environment: Add a step in your pipeline to print environment information:

echo $PATH
which serverless
serverless --version
  1. Permissions: Ensure the Jenkins user has read/execute permissions for the serverless executable and read permissions for your project files.

  2. Consider Using Docker: You could use a Docker container with Serverless pre-installed for your build, similar to how AWS SAM pipelines work. This ensures a consistent environment for your builds.

  3. serverless.yaml Location: Verify that your serverless.yaml file is in the correct location relative to where the command is being executed. Jenkins might be running the command from a different directory than expected.

If you're using a Gradle task to run Serverless, make sure the task is properly configured to find and execute the serverless command. You might need to explicitly set the working directory or provide the full path to your serverless.yaml file.

 

If the above information is not able to assist you in resolving the error you are experiencing, you may want to consider opening an AWS support case with the Serverless Application Model (SAM) team for further assistance/guidance.

 

Sources
Not able to run jenkins on AWS EC2 instance | AWS re:Post
Broken connection with EC2 node during execution | AWS re:Post
Using Jenkins to deploy with AWS SAM - AWS Serverless Application Model

answered a year ago

AWS
SUPPORT ENGINEER

reviewed a year ago

AWS
SUPPORT ENGINEER

revised a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.