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

Pipeline support #26

Closed
wants to merge 15 commits into from
Closed
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ buildNumber.properties
*.ipr
*.iws

.me/
.me/
workflow/
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sudo: required
sudo: false

cache:
directories:
Expand All @@ -9,4 +9,6 @@ jdk: [oraclejdk8, oraclejdk7]
language: java

script:
- mvn clean verify -P$TRAVIS_BRANCH
- mvn clean compile verify -P$TRAVIS_BRANCH

dist: trusty
90 changes: 48 additions & 42 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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.5</version>
<relativePath />
<relativePath/>
</parent>

<artifactId>aws-codecommit-trigger</artifactId>
Expand All @@ -24,7 +25,8 @@

<scm>
<connection>scm:git:ssh://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:ssh://[email protected]/jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<developerConnection>scm:git:ssh://[email protected]/jenkinsci/${project.artifactId}-plugin.git
</developerConnection>
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
</scm>

Expand Down Expand Up @@ -73,28 +75,6 @@
</pluginRepositories>

<dependencies>
<!--dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-json-org</artifactId>
<version>2.8.9</version>
</dependency-->

<!--dependency>
<groupId>net.openhft</groupId>
<artifactId>chronicle</artifactId>
<version>3.6.4</version>
</dependency-->

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
Expand Down Expand Up @@ -126,6 +106,18 @@
<optional>true</optional>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<optional>true</optional>
<version>2.14</version>
</dependency>
<!--dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-scm-step</artifactId>
<optional>true</optional>
<version>2.6</version>
</dependency-->

<dependency>
<groupId>com.google.inject</groupId>
Expand Down Expand Up @@ -210,19 +202,48 @@
<version>0.3.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.38</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.21</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<skipTests>false</skipTests>
</configuration>
</plugin>

<plugin>
<groupId>org.jvnet.localizer</groupId>
<artifactId>maven-localizer-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<fileMask>Messages.properties</fileMask>
<outputDirectory>target/generated-sources/localizer</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>external.atlassian.jgitflow</groupId>
<artifactId>jgitflow-maven-plugin</artifactId>
Expand All @@ -240,20 +261,6 @@
</flowInitContext>
</configuration>
</plugin>

<!--plugin>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<version>3.3.0.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin-->
</plugins>
</build>

Expand All @@ -263,7 +270,7 @@
<id>it</id>
<activation>
<property>
<name>performRelease</name>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
Expand All @@ -286,5 +293,4 @@
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public SQSActivityAction(Job job) {
log.error("Unable to create trigger activity dir %s", this.activityDir.getPath());
}

log.info("Activity dir %s is writeable? %s", this.activityDir.getPath(), this.activityDir.canWrite());
log.debug("Activity dir %s is writeable? %s", this.activityDir.getPath(), this.activityDir.canWrite());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.ribose.jenkins.plugin.awscodecommittrigger;

import com.ribose.jenkins.plugin.awscodecommittrigger.i18n.SQSScmConfig.Messages;
import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.plugins.git.BranchSpec;
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.SubmoduleConfig;
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.util.FormValidation;
import net.sf.json.JSONObject;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.export.ExportedBean;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


@ExportedBean
public class SQSScmConfig extends AbstractDescribableImpl<SQSScmConfig> {

public enum Type {IR, ER}

private String subscribedBranches;
private Type type;
private String url;

private transient List<BranchSpec> branchSpecs;

@DataBoundConstructor
public SQSScmConfig(Type type, String url, String subscribedBranches) {
this.subscribedBranches = subscribedBranches;
this.type = type;

if (this.type == Type.IR) {
url = "";
}
this.url = url;
}

public String getSubscribedBranches() {
return subscribedBranches;
}

public Type getType() {
return type;
}

public String getUrl() {
return url;
}

public List<BranchSpec> getBranchSpecs() {
if (CollectionUtils.isEmpty(branchSpecs)) {
branchSpecs = new ArrayList<>();
List<String> branches = com.ribose.jenkins.plugin.awscodecommittrigger.utils.StringUtils.parseCsvString(subscribedBranches);
for (String branch : branches) {
branchSpecs.add(new BranchSpec(branch));
}
}
return branchSpecs;
}

public GitSCM toGitSCM() {
return new GitSCM(
GitSCM.createRepoList(this.url, null),
// Collections.singletonList(new BranchSpec("")),
getBranchSpecs(),
false,
Collections.<SubmoduleConfig>emptyList(),
null,
null,
Collections.<GitSCMExtension>emptyList()
);
}

@Extension
public static class DescriptorImpl extends Descriptor<SQSScmConfig> {

// public FormValidation doCheckSubscribedBranches(@QueryParameter final String subscribedBranches) {
// if (StringUtils.isBlank(subscribedBranches)) {
// return FormValidation.warning(Messages.warningSubscribedBranches());
// }
// return FormValidation.ok();
// }

@Override
public SQSScmConfig newInstance(StaplerRequest req, JSONObject jsonObject) throws FormException {
JSONObject json = jsonObject.getJSONObject("type");
json.put("type", json.getString("value"));
json.remove("value");
return super.newInstance(req, json);//req.bindJSON(SQSScmConfig.class, json);
}

public FormValidation doCheckUrl(@QueryParameter final String url) {
if (StringUtils.isBlank(url)) {
return FormValidation.warning(Messages.warningBlankUrl());
}
return com.ribose.jenkins.plugin.awscodecommittrigger.utils.StringUtils.isCodeCommitRepo(url)
? FormValidation.ok()
: FormValidation.error(Messages.errorCodeCommitUrlInvalid());
}

// public String getSubscribeBranchPage() {
// return getViewPage(clazz, "subscribedBranches.jelly");
// }
}
}
Loading