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

<ul>
<li>Create your Lambda function as a Maven project using the <a href="http://docs.aws.amazon.com/lambda/latest/dg/java-create-jar-pkg-maven-no-ide.html" rel="nofollow noreferrer">AWS documentation</a>.</li>
<li>Create your Jenkins job as a Maven project and specify <code>package</code> in the goals section.</li>
<li>Follow the Jenkins Lambda plugin <a href="https://wiki.jenkins.io/display/JENKINS/AWS+Lambda+Plugin" rel="nofollow noreferrer">documentation</a> for deployment and specify <code>target/your-project-1.0-SNAPSHOT.jar</code> as the Artifact location.</li>
</ul>

<p>This should build your Lambda function with Maven and then deploy it to AWS.</p>

CC BY-SA 3.0
2017-07-03T11:39:03.393Z
2017-07-03T11:39:03.393Z
Anish Sana
<p>I have a simple Lambda function that I'm trying to deploy through Jenkins -</p>

<pre><code>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;
    }
</code></pre>

<p>I'm able to deploy and invoke this through Eclipse's AWS Lambda plugin without any problems.</p>

<p>I'm using the AWS Lambda plugin for Jenkins and following their <a href="https://wiki.jenkins.io/display/JENKINS/AWS+Lambda+Plugin" rel="noreferrer">documentation</a>.</p>

<ul>
<li>I'm providing my <a href="https://github.com/anishsana/HelloFunction/" rel="noreferrer">Git repository</a> as the source.</li>
<li>Artifact Location - <code>src/main/java/</code></li>
<li>Handler Name - <code>lambda.Hello</code> (<em>lambda</em> is the package name and <em>Hello</em> is the class name). I've also tried using <code>lambda.Hello.handleRequest</code>,  <code>lambda.Hello::handleRequest</code> and other variations.</li>
</ul>

<p>Jenkins says that the build was successful but when I test it on the AWS console, I'm getting -</p>

<pre><code>"errorMessage": "Class not found: lambda.Hello",
  "errorType": "class java.lang.ClassNotFoundException"
</code></pre>

<p>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.</p>

<jenkins><continuous-integration><jenkins-plugins><continuous-deployment><aws-lambda>
How can I deploy an AWS Lambda function from Jenkins?
Anish Sana
# How can I deploy an AWS Lambda function from Jenkins?

(Asked by: username_0 on 2017-07-02)

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.

**Tags:** jenkins, continuous-integration, jenkins-plugins, continuous-deployment, aws-lambda


---

## 1 answers

### Answer by username_0 on 2017-07-03. Score: 3 | Accepted answer

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](http://docs.aws.amazon.com/lambda/latest/dg/java-create-jar-pkg-maven-no-ide.html).
* Create your Jenkins job as a Maven project and specify `package` in the goals section.
* Follow the Jenkins Lambda plugin [documentation](https://wiki.jenkins.io/display/JENKINS/AWS+Lambda+Plugin) 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.


---

