7

I have a simple Lambda function that I'm trying to deploy through Jenkins -

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 using lambda.Hello.handleRequest, lambda.Hello::handleRequest and 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.

3

I found the solution while trying to manually deploy the Lambda function as a jar file. These are the steps -

  • Create your Lambda function as a Maven project using the AWS documentation.
  • Create your Jenkins job as a Maven project and specify package in the goals section.
  • Follow the Jenkins Lambda plugin documentation for deployment and specify target/your-project-1.0-SNAPSHOT.jar as the Artifact location.

This should build your Lambda function with Maven and then deploy it to AWS.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.