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

Initial steps to add pipeline step plus README info #75

Open
wants to merge 2 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
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,26 @@ Jenkins Plugin for AWS Elastic Beanstalk Deployments
* Support Job DSL and Workflow Plugins
* Ensure parameters are properly dealt
* See https://github.com/jenkinsci/credentials-plugin/issues/35

## Using AWSEB in the pipeline

With credentials saved using Jenkins Credentials plugin, you can use the following snippet to use the code:

```groovy
script {
def files = findFiles(glob: "build/libs/*.war")
def date = new Date()
def version = env.BRANCH_NAME + "-" + sha() + "-" + date.format('yyyyMMdd.HHmm')

echo """WAR File -> ${files[0].name} ${files[0].path} ${files[0].directory} ${files[0].length} ${files[0].lastModified}"""
awsEbDeployment zeroDowntime: false,
awsRegion: "(REGION)",
credentialId: "(YOUR SAVED CREDS)",
applicationName: "(APP_NAME)",
environmentName: "(ENV_NAME)",
bucketName: "(S3_BUCKET_NAME)",
keyPrefix: "(S3_BUCKET_PREFIX)",
rootObject: files[0].path,
versionLabelFormat: version
}
```
25 changes: 25 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,31 @@
<version>1.16.6</version>
<scope>provided</scope>
</dependency>

<!-- dependencies on Jenkins Pipeline plugins -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>1.14</version>
</dependency>

<!-- writeFile is useful for test -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>1.14</version>
<scope>test</scope>
</dependency>
</dependencies>

<!-- get every artifact through repo.jenkins-ci.org, which proxies all the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,22 @@ public DescriptorImpl getDescriptor() {

public AWSEBDeploymentConfig asConfig() {
return new AWSEBDeploymentConfig(
credentialId,
awsRegion,
applicationName,
environmentName,
bucketName,
keyPrefix,
versionLabelFormat,
versionDescriptionFormat,
rootObject,
includes,
excludes,
zeroDowntime,
sleepTime,
checkHealth,
maxAttempts,
null);
credentialId,
awsRegion,
applicationName,
environmentName,
bucketName,
keyPrefix,
versionLabelFormat,
versionDescriptionFormat,
rootObject,
includes,
excludes,
zeroDowntime,
sleepTime,
checkHealth,
maxAttempts,
null);
}

@Extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package br.com.ingenieux.jenkins.plugins.awsebdeployment;

import com.cloudbees.jenkins.plugins.awscredentials.AmazonWebServicesCredentials;
Expand All @@ -25,15 +24,36 @@
import org.jenkinsci.plugins.tokenmacro.MacroEvaluationException;

@NoArgsConstructor
@AllArgsConstructor
@Data
@ToString(exclude={"credentials"})
public class AWSEBDeploymentConfig implements Serializable {
public AWSEBDeploymentConfig(String credentialId, String awsRegion, String applicationName,
String environmentName, String bucketName, String keyPrefix,
String versionLabelFormat, String versionDescriptionFormat,
String rootObject, String includes, String excludes,
boolean zeroDowntime, Integer sleepTime, boolean checkHealth,
Integer maxAttempts, AmazonWebServicesCredentials credentials)
{
this.credentialId = credentialId;
this.awsRegion = awsRegion;
this.applicationName = applicationName;
this.environmentName = environmentName;
this.bucketName = bucketName;
this.keyPrefix = keyPrefix;
this.versionLabelFormat = versionLabelFormat;
this.versionDescriptionFormat = versionDescriptionFormat;
this.rootObject = rootObject;
this.includes = includes;
this.excludes = excludes;
this.zeroDowntime = zeroDowntime;
this.sleepTime = sleepTime;
this.checkHealth = checkHealth;
this.maxAttempts = maxAttempts;
this.credentials = credentials;
}

private static final long serialVersionUID = 1L;

/**
* Credentials name
*/
private String credentialId;

/**
Expand All @@ -56,61 +76,157 @@ public class AWSEBDeploymentConfig implements Serializable {
*/
private String bucketName;

public String getBucketName() {
return this.bucketName;
}

public void setBucketName(final String bucketName) {
this.bucketName = bucketName;
}

/**
* Key Format
*/
private String keyPrefix;

public String getKeyPrefix() {
return this.keyPrefix;
}

public void setKeyPrefix(final String keyPrefix) {
this.keyPrefix = keyPrefix;
}

/**
* Version Label Format
* Version Label
*/
private String versionLabelFormat;

public String getVersionLabelFormat() {
return this.versionLabelFormat;
}

public void setVersionLabelFormat(final String versionLabelFormat) {
this.versionLabelFormat = versionLabelFormat;
}

/**
* Version Description Format
* Version Description
*/
private String versionDescriptionFormat;

public String getVersionDescriptionFormat() {
return this.versionDescriptionFormat;
}

public void setVersionDescriptionFormat(final String versionDescriptionFormat) {
this.versionDescriptionFormat = versionDescriptionFormat;
}

/**
* Root Object
*/
private String rootObject;

public String getRootObject() {
return this.rootObject;
}

public void setRootObject(final String rootObject) {
this.rootObject = rootObject;
}

/**
* Includes
*/
private String includes;

public String getIncludes() {
return this.includes;
}

public void setIncludes(final String includes) {
this.includes = includes;
}

/**
* Excludes
*/
private String excludes;

public String getExcludes() {
return this.excludes;
}

public void setExcludes(final String excludes) {
this.excludes = excludes;
}

/**
* Zero Downtime
*/
private boolean zeroDowntime;

public boolean isZeroDowntime() {
return this.zeroDowntime;
}

public void setZeroDowntime(final boolean zeroDowntime) {
this.zeroDowntime = zeroDowntime;
}

/**
* Deployment Sleep Time
* Deploy Sleep Time
*/
private Integer sleepTime;

public Integer getSleepTime() {
return sleepTime;
}

public void setSleepTime(final Integer sleepTime) {
this.sleepTime = sleepTime;
}

/**
* Check Health
*/
private boolean checkHealth;

public boolean isCheckHealth() {
return checkHealth;
}

public void setCheckHealth(final boolean checkHealth) {
this.checkHealth = checkHealth;
}

/**
* Max Number Of Attempts
*/
private Integer maxAttempts;

public Integer getMaxAttempts() {
return maxAttempts;
}

public void setMaxAttempts(final Integer maxAttempts) {
this.maxAttempts = maxAttempts;
}

/**
* Credentials
*/
private AmazonWebServicesCredentials credentials;

public AmazonWebServicesCredentials getCredentials() {
return credentials;
}

public void setCredentials(final AmazonWebServicesCredentials credentials) {
this.credentials = credentials;
}

/**
* Copy Factory
*
Expand Down
Loading