forked from XT-i/aws-lambda-jenkins-plugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TDD refactoring
- Loading branch information
Showing
17 changed files
with
134 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/com/xti/jenkins/plugin/awslambda/service/WorkSpaceZipper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.xti.jenkins.plugin.awslambda.service; | ||
|
||
import hudson.FilePath; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
|
||
public class WorkSpaceZipper { | ||
private FilePath workSpace; | ||
private JenkinsLogger logger; | ||
|
||
public WorkSpaceZipper(FilePath workSpace, JenkinsLogger logger) { | ||
this.workSpace = workSpace; | ||
this.logger = logger; | ||
} | ||
|
||
public File getZip(String artifactLocation) throws IOException, InterruptedException { | ||
FilePath artifactFilePath = null; | ||
|
||
if(StringUtils.isNotEmpty(artifactLocation)) { | ||
artifactFilePath = new FilePath(workSpace, artifactLocation); | ||
} | ||
File zipFile = null; | ||
if(artifactFilePath != null){ | ||
zipFile = getArtifactZip(artifactFilePath); | ||
} | ||
|
||
return zipFile; | ||
} | ||
|
||
private File getArtifactZip(FilePath artifactLocation) throws IOException, InterruptedException { | ||
File resultFile = File.createTempFile("awslambda-", ".zip"); | ||
|
||
if (!artifactLocation.isDirectory()) { | ||
logger.log("Copying zip file"); | ||
artifactLocation.copyTo(new FileOutputStream(resultFile)); | ||
} else { | ||
logger.log("Zipping folder ..., copying zip file"); | ||
artifactLocation.zip(new FileOutputStream(resultFile)); | ||
} | ||
|
||
logger.log("File Name: %s%nAbsolute Path: %s%nFile Size: %d", resultFile.getName(), resultFile.getAbsolutePath(), resultFile.length()); | ||
return resultFile; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.