Skip to content

Add support for environment defined into build of jenkins. #15

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
81 changes: 81 additions & 0 deletions pom.xml.releaseBackup
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.19</version>
</parent>

<artifactId>codedeploy</artifactId>
<version>1.15-SNAPSHOT</version>
<packaging>hpi</packaging>
<groupId>com.amazonaws</groupId>
<name>AWS CodeDeploy Plugin for Jenkins</name>
<description>Adds a post-build step to integrate Jenkins with AWS CodeDeploy</description>
<url>https://wiki.jenkins-ci.org/display/JENKINS/AWS+Codedeploy+plugin</url>

<developers>
<developer>
<id>jmcfar</id>
<name>Josh McFarlane</name>
<email>jmcfar@amazon.com</email>
</developer>
</developers>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:ssh://github.com/jenkinsci/aws-codedeploy-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/aws-codedeploy-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/aws-codedeploy-plugin</url>
<tag>HEAD</tag>
</scm>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jenkins.version>1.580.3</jenkins.version>
</properties>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.37</version>
</dependency>
</dependencies>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
</plugins>
</build>
</project>
19 changes: 19 additions & 0 deletions release.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#release configuration
#Tue Nov 15 18:25:09 UTC 2016
project.rel.com.amazonaws\:codedeploy=1.15
scm.tagNameFormat=@{project.artifactId}-@{project.version}
scm.tag=codedeploy-1.15
project.scm.com.amazonaws\:codedeploy.tag=HEAD
pushChanges=true
scm.url=scm\:git\:ssh\://git@github.com/jenkinsci/aws-codedeploy-plugin.git
preparationGoals=clean install
project.scm.com.amazonaws\:codedeploy.url=https\://github.com/jenkinsci/aws-codedeploy-plugin
project.dev.com.amazonaws\:codedeploy=1.16-SNAPSHOT
project.scm.com.amazonaws\:codedeploy.connection=scm\:git\:ssh\://github.com/jenkinsci/aws-codedeploy-plugin.git
remoteTagging=true
projectVersionPolicyId=default
scm.commentPrefix=[maven-release-plugin]
project.scm.com.amazonaws\:codedeploy.developerConnection=scm\:git\:ssh\://git@github.com/jenkinsci/aws-codedeploy-plugin.git
exec.snapshotReleasePluginAllowed=false
exec.additionalArguments=
completedPhase=end-release
12 changes: 6 additions & 6 deletions src/main/java/com/amazonaws/codedeploy/AWSClients.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
*
* http://aws.amazon.com/apache2.0
*
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
Expand Down Expand Up @@ -82,15 +82,15 @@ public AWSClients(String region, AWSCredentials credentials, String proxyHost, i
codedeploy.setRegion(Region.getRegion(Regions.fromName(this.region)));
s3.setRegion(Region.getRegion(Regions.fromName(this.region)));
}

public static AWSClients fromDefaultCredentialChain(String region, String proxyHost, int proxyPort) {
return new AWSClients(region, null, proxyHost, proxyPort);
}

public static AWSClients fromIAMRole(String region, String iamRole, String externalId, String proxyHost, int proxyPort) {
return new AWSClients(region, getCredentials(iamRole, externalId), proxyHost, proxyPort);
}

public static AWSClients fromBasicCredentials(String region, String awsAccessKey, String awsSecretKey, String proxyHost, int proxyPort) {
return new AWSClients(region, new BasicAWSCredentials(awsAccessKey, awsSecretKey), proxyHost, proxyPort);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,21 @@ public void perform(@Nonnull Run<?,?> build, @Nonnull FilePath workspace, @Nonnu
this.proxyHost,
this.proxyPort);
} else {
aws = AWSClients.fromBasicCredentials(
if (StringUtils.isEmpty(envVars.get(this.awsAccessKey)) && StringUtils.isEmpty(envVars.get(this.awsSecretKey))) {
aws = AWSClients.fromBasicCredentials(
this.region,
this.awsAccessKey,
Secret.toString(this.awsSecretKey),
this.proxyHost,
this.proxyPort);
} else {
aws = AWSClients.fromBasicCredentials(
this.region,
envVars.get(this.awsAccessKey),
envVars.get(this.awsSecretKey),
this.proxyHost,
this.proxyPort);
}
}
} else {
aws = AWSClients.fromIAMRole(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<div>
<p>AWS Access and Secret keys to use for this deployment. At minimum the keys must be allowed to execute
<code>codedeploy:*</code> and <code>s3:Put*</code>. It's a best practice to have these keys be from an IAM role
<code>codedeploy:*</code> and <code>s3:Put*</code>.
You can also use environment variables defined in jenkins's build for this fields.
It's a best practice to have these keys be from an IAM role
with limited scope.</p>

<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<div>
<p>AWS Access and Secret keys to use for this deployment. At minimum the keys must be allowed to execute
<code>codedeploy:*</code> and <code>s3:Put*</code>. It's a best practice to have these keys be from an IAM role
<code>codedeploy:*</code> and <code>s3:Put*</code>.
You can also use environment variables defined in jenkins's build for this fields.
It's a best practice to have these keys be from an IAM role
with limited scope.</p>

<p>
Expand Down