Skip to content
Permalink
Browse files
JENKINS-28443
Added AWS Lambda post build action

awaiting testing for Lambda invocation
  • Loading branch information
cast committed May 23, 2015
1 parent 0d68c97 commit 8efb77aa0b4743ba38f8a34da90316ea3a325ab7
Showing with 1,115 additions and 178 deletions.
  1. +7 −4 src/main/java/com/xti/jenkins/plugin/awslambda/AWSLambdaPublisher.java
  2. +8 −0 src/main/java/com/xti/jenkins/plugin/awslambda/LambdaVariables.java
  3. +89 −0 src/main/java/com/xti/jenkins/plugin/awslambda/invoke/InvokeConfig.java
  4. +0 −16 src/main/java/com/xti/jenkins/plugin/awslambda/invoke/JsonParameter.java
  5. +76 −0 src/main/java/com/xti/jenkins/plugin/awslambda/invoke/JsonParameterVariables.java
  6. +71 −0 src/main/java/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokeAction.java
  7. +15 −13 src/main/java/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokeBuildStep.java
  8. +154 −0 src/main/java/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokeBuildStepVariables.java
  9. +157 −0 src/main/java/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokePublisher.java
  10. +13 −5 src/main/java/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokeVariables.java
  11. +2 −2 src/main/java/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvoker.java
  12. +7 −7 src/main/java/com/xti/jenkins/plugin/awslambda/service/LambdaService.java
  13. +4 −4 ...va/com/xti/jenkins/plugin/awslambda/{LambdaProminentAction.java → upload/LambdaUploadAction.java}
  14. +15 −23 src/main/java/com/xti/jenkins/plugin/awslambda/upload/LambdaUploadBuildStep.java
  15. +233 −0 src/main/java/com/xti/jenkins/plugin/awslambda/upload/LambdaUploadBuildStepVariables.java
  16. +5 −4 src/main/java/com/xti/jenkins/plugin/awslambda/upload/LambdaUploader.java
  17. +137 −0 src/main/java/com/xti/jenkins/plugin/awslambda/upload/UploadConfig.java
  18. +2 −11 src/main/resources/com/xti/jenkins/plugin/awslambda/AWSLambdaPublisher/config.jelly
  19. +1 −1 src/main/resources/com/xti/jenkins/plugin/awslambda/LambdaVariables/config.jelly
  20. 0 ...ces/com/xti/jenkins/plugin/awslambda/invoke/{JsonParameter → JsonParameterVariables}/config.jelly
  21. +1 −1 src/main/resources/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokeBuildStep/config.jelly
  22. +31 −0 ...ain/resources/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokeBuildStepVariables/config.jelly
  23. +38 −0 src/main/resources/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokePublisher/config.jelly
  24. +0 −86 src/main/resources/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokeVariables/config.jelly
  25. +1 −1 src/main/resources/com/xti/jenkins/plugin/awslambda/upload/LambdaUploadBuildStep/config.jelly
  26. +48 −0 ...ain/resources/com/xti/jenkins/plugin/awslambda/upload/LambdaUploadBuildStepVariables/config.jelly
@@ -26,7 +26,9 @@
* #L%
*/

import com.xti.jenkins.plugin.awslambda.upload.LambdaUploadAction;
import com.xti.jenkins.plugin.awslambda.upload.LambdaUploader;
import com.xti.jenkins.plugin.awslambda.upload.UploadConfig;
import hudson.Extension;
import hudson.Launcher;
import hudson.model.AbstractBuild;
@@ -83,15 +85,16 @@ public boolean perform(LambdaVariables lambdaVariables,AbstractBuild<?, ?> build
}
try {
LambdaVariables executionVariables = lambdaVariables.getClone();

executionVariables.expandVariables(build.getEnvironment(listener));
LambdaUploader lambdaUploader = new LambdaUploader(executionVariables, build, listener);
UploadConfig uploadConfig = executionVariables.getUploadConfig();

LambdaUploader lambdaUploader = new LambdaUploader(uploadConfig, build, listener);

Boolean lambdaSuccess = lambdaUploader.upload();
if(!lambdaSuccess){
build.setResult(Result.FAILURE);
}
build.addAction(new LambdaProminentAction(executionVariables.getFunctionName(), lambdaSuccess));
build.addAction(new LambdaUploadAction(executionVariables.getFunctionName(), lambdaSuccess));
return true;
} catch (Exception exc) {
throw new RuntimeException(exc);
@@ -135,7 +138,7 @@ public boolean isApplicable(Class<? extends AbstractProject> aClass) {
* This human readable name is used in the configuration screen.
*/
public String getDisplayName() {
return "Deploy into Lambda";
return "AWS Lambda deployment";
}

@Override
@@ -27,6 +27,7 @@
*/

import com.xti.jenkins.plugin.awslambda.upload.UpdateModeValue;
import com.xti.jenkins.plugin.awslambda.upload.UploadConfig;
import hudson.EnvVars;
import hudson.Extension;
import hudson.Util;
@@ -36,6 +37,9 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

/**
* Describable containing Lambda post build action config, checking feasability of migrating it to upload package.
*/
public class LambdaVariables extends AbstractDescribableImpl<LambdaVariables> {
private String awsAccessKeyId;
private String awsSecretKey;
@@ -188,6 +192,10 @@ public LambdaVariables getClone(){
return new LambdaVariables(awsAccessKeyId, awsSecretKey, awsRegion, artifactLocation, description, functionName, handler, memorySize, role, runtime, timeout, successOnly, updateMode);
}

public UploadConfig getUploadConfig(){
return new UploadConfig(awsAccessKeyId, awsSecretKey, awsRegion, artifactLocation, description, functionName, handler, memorySize, role, runtime, timeout, successOnly, updateMode);
}

private String expand(String value, EnvVars env) {
return Util.replaceMacro(value.trim(), env);
}
@@ -0,0 +1,89 @@
package com.xti.jenkins.plugin.awslambda.invoke;

import java.util.List;

public class InvokeConfig {
private String awsAccessKeyId;
private String awsSecretKey;
private String awsRegion;
private String functionName;
private String payload;
private boolean synchronous;
private boolean successOnly;
private List<JsonParameter> jsonParameters;

public InvokeConfig(String awsAccessKeyId, String awsSecretKey, String awsRegion, String functionName, String payload, boolean synchronous, boolean successOnly, List<JsonParameter> jsonParameters) {
this.awsAccessKeyId = awsAccessKeyId;
this.awsSecretKey = awsSecretKey;
this.awsRegion = awsRegion;
this.functionName = functionName;
this.payload = payload;
this.synchronous = synchronous;
this.successOnly = successOnly;
this.jsonParameters = jsonParameters;
}

public String getAwsAccessKeyId() {
return awsAccessKeyId;
}

public void setAwsAccessKeyId(String awsAccessKeyId) {
this.awsAccessKeyId = awsAccessKeyId;
}

public String getAwsSecretKey() {
return awsSecretKey;
}

public void setAwsSecretKey(String awsSecretKey) {
this.awsSecretKey = awsSecretKey;
}

public String getAwsRegion() {
return awsRegion;
}

public void setAwsRegion(String awsRegion) {
this.awsRegion = awsRegion;
}

public String getFunctionName() {
return functionName;
}

public void setFunctionName(String functionName) {
this.functionName = functionName;
}

public String getPayload() {
return payload;
}

public void setPayload(String payload) {
this.payload = payload;
}

public boolean isSynchronous() {
return synchronous;
}

public void setSynchronous(boolean synchronous) {
this.synchronous = synchronous;
}

public boolean isSuccessOnly() {
return successOnly;
}

public void setSuccessOnly(boolean successOnly) {
this.successOnly = successOnly;
}

public List<JsonParameter> getJsonParameters() {
return jsonParameters;
}

public void setJsonParameters(List<JsonParameter> jsonParameters) {
this.jsonParameters = jsonParameters;
}
}
@@ -26,16 +26,12 @@
* #L%
*/

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import org.kohsuke.stapler.DataBoundConstructor;

public class JsonParameter extends AbstractDescribableImpl<JsonParameter> {
private String envVarName;
private String jsonPath;

@DataBoundConstructor
public JsonParameter(String envVarName, String jsonPath) {
this.envVarName = envVarName;
this.jsonPath = jsonPath;
@@ -57,16 +53,4 @@ public void setJsonPath(String jsonPath) {
this.jsonPath = jsonPath;
}

@Extension // This indicates to Jenkins that this is an implementation of an extension point.
public static class DescriptorImpl extends Descriptor<JsonParameter> {

/**
* This human readable name is used in the configuration screen.
*/
public String getDisplayName() {
return "Environment Variable";
}


}
}
@@ -0,0 +1,76 @@
package com.xti.jenkins.plugin.awslambda.invoke;

/*
* #%L
* AWS Lambda Upload Plugin
* %%
* Copyright (C) 2015 XT-i
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* #L%
*/

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import org.kohsuke.stapler.DataBoundConstructor;

public class JsonParameterVariables extends AbstractDescribableImpl<JsonParameterVariables> {
private String envVarName;
private String jsonPath;

@DataBoundConstructor
public JsonParameterVariables(String envVarName, String jsonPath) {
this.envVarName = envVarName;
this.jsonPath = jsonPath;
}

public String getEnvVarName() {
return envVarName;
}

public String getJsonPath() {
return jsonPath;
}

public void setEnvVarName(String envVarName) {
this.envVarName = envVarName;
}

public void setJsonPath(String jsonPath) {
this.jsonPath = jsonPath;
}

public JsonParameter getJsonParameter(){
return new JsonParameter(envVarName, jsonPath);
}

@Extension // This indicates to Jenkins that this is an implementation of an extension point.
public static class DescriptorImpl extends Descriptor<JsonParameterVariables> {

/**
* This human readable name is used in the configuration screen.
*/
public String getDisplayName() {
return "Environment Variable";
}


}
}
@@ -0,0 +1,71 @@
package com.xti.jenkins.plugin.awslambda.invoke;

/*
* #%L
* AWS Lambda Upload Plugin
* %%
* Copyright (C) 2015 XT-i
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* #L%
*/

import hudson.model.ProminentProjectAction;

public class LambdaInvokeAction implements ProminentProjectAction {

//Nothing to show, go to console for now
private static final String URL_NAME = "console";

private final String iconFileName;
private final String bigIconFileName;
private final String displayName;


public LambdaInvokeAction(String functionName, Boolean success) {
if(success){
iconFileName = "/plugin/aws-lambda/images/Lambda_24.png";
bigIconFileName = "/plugin/aws-lambda/images/Lambda_48.png";
displayName = "Invoked Lambda: " + functionName;
}else {
iconFileName = "/plugin/aws-lambda/images/Lambda_24_grey.png";
bigIconFileName = "/plugin/aws-lambda/images/Lambda_48_grey.png";
displayName = "Lambda Invocation Failure: " + functionName;
}
}

@Override
public String getIconFileName() {
return iconFileName;
}

public String getBigIconFileName() {
return bigIconFileName;
}

@Override
public String getDisplayName() {
return displayName;
}

@Override
public String getUrlName() {
return URL_NAME;
}
}
Loading

0 comments on commit 8efb77a

Please sign in to comment.