Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow override revision zip filename with Environment var #114

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@
* credentials to be configured for each project.
*/
public class AWSCodeDeployPublisher extends Publisher implements SimpleBuildStep {
public static final long DEFAULT_TIMEOUT_SECONDS = 900;
public static final long DEFAULT_POLLING_FREQUENCY_SECONDS = 15;
public static final String ROLE_SESSION_NAME = "jenkins-codedeploy-plugin";
private static final Regions[] AVAILABLE_REGIONS = {Regions.AP_NORTHEAST_1, Regions.AP_SOUTHEAST_1, Regions.AP_SOUTHEAST_2, Regions.EU_WEST_1, Regions.US_EAST_1, Regions.US_WEST_2, Regions.EU_CENTRAL_1, Regions.US_WEST_1, Regions.SA_EAST_1, Regions.AP_NORTHEAST_2, Regions.AP_SOUTH_1, Regions.US_EAST_2, Regions.CA_CENTRAL_1, Regions.EU_WEST_2, Regions.CN_NORTH_1};
public static final long DEFAULT_TIMEOUT_SECONDS = 900;
public static final long DEFAULT_POLLING_FREQUENCY_SECONDS = 15;
public static final String ROLE_SESSION_NAME = "jenkins-codedeploy-plugin";
public static final String CODE_DEPLOY_REVISION_ZIP_FILENAME = "CODE_DEPLOY_REVISION_ZIP_FILENAME";
private static final Regions[] AVAILABLE_REGIONS = {Regions.AP_NORTHEAST_1, Regions.AP_SOUTHEAST_1, Regions.AP_SOUTHEAST_2, Regions.EU_WEST_1, Regions.US_EAST_1, Regions.US_WEST_2, Regions.EU_CENTRAL_1, Regions.US_WEST_1, Regions.SA_EAST_1, Regions.AP_NORTHEAST_2, Regions.AP_SOUTH_1, Regions.US_EAST_2, Regions.CA_CENTRAL_1, Regions.EU_WEST_2, Regions.CN_NORTH_1};

private final String s3bucket;
private final String s3prefix;
Expand Down Expand Up @@ -316,6 +317,7 @@ private RevisionLocation zipAndUpload(AWSClients aws, String projectName, FilePa
File zipFile = null;
File versionFile;
versionFile = new File(sourceDirectory + "/" + versionFileName);
String zipFileNameFromEnv = envVars.get(CODE_DEPLOY_REVISION_ZIP_FILENAME);

InputStreamReader reader = null;
String version = null;
Expand All @@ -331,7 +333,9 @@ private RevisionLocation zipAndUpload(AWSClients aws, String projectName, FilePa
if(reader !=null){reader.close();}
}

if (version != null){
if (StringUtils.isNotEmpty(zipFileNameFromEnv)) {
zipFile = File.createTempFile(zipFileNameFromEnv, ".zip");
} else if (version != null){
zipFile = new File("/tmp/" + projectName + "-" + version + ".zip");
final boolean fileCreated = zipFile.createNewFile();
if (!fileCreated) {
Expand Down