snippetMinor
How can I deploy an AWS Lambda function from Jenkins?
Viewed 0 times
canjenkinsfunctiondeployawshowfromlambda
Problem
I have a simple Lambda function that I'm trying to deploy through Jenkins -
I'm able to deploy and invoke this through Eclipse's AWS Lambda plugin without any problems.
I'm using the AWS Lambda plugin for Jenkins and following their documentation.
Jenkins says that the build was successful but when I test it on the AWS console, I'm getting -
Where am I going wrong here? When I export the test function from AWS and unzip it, I can see that code on Git definitely got deployed but it's unable find the class.
public String handleRequest(String input, Context context) {
String output = "";
if (input.isEmpty()) {
output = "No input provided";
} else {
output = "Hello, " + input + "! Checking invocation - 1";
}
return output;
}I'm able to deploy and invoke this through Eclipse's AWS Lambda plugin without any problems.
I'm using the AWS Lambda plugin for Jenkins and following their documentation.
- I'm providing my Git repository as the source.
- Artifact Location -
src/main/java/
- Handler Name -
lambda.Hello(lambda is the package name and Hello is the class name). I've also tried usinglambda.Hello.handleRequest,lambda.Hello::handleRequestand other variations.
Jenkins says that the build was successful but when I test it on the AWS console, I'm getting -
"errorMessage": "Class not found: lambda.Hello",
"errorType": "class java.lang.ClassNotFoundException"Where am I going wrong here? When I export the test function from AWS and unzip it, I can see that code on Git definitely got deployed but it's unable find the class.
Solution
I found the solution while trying to manually deploy the Lambda function as a jar file. These are the steps -
This should build your Lambda function with Maven and then deploy it to AWS.
- Create your Lambda function as a Maven project using the AWS documentation.
- Create your Jenkins job as a Maven project and specify
packagein the goals section.
- Follow the Jenkins Lambda plugin documentation for deployment and specify
target/your-project-1.0-SNAPSHOT.jaras the Artifact location.
This should build your Lambda function with Maven and then deploy it to AWS.
Context
StackExchange DevOps Q#1469, answer score: 3
Revisions (0)
No revisions yet.