diff --git a/pom.xml b/pom.xml index ec2d9e8..58b1d83 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,4 @@ - 4.0.0 diff --git a/src/main/java/com/dabsquared/gitlabjenkins/GitLabProjectBranchesService.java b/src/main/java/com/dabsquared/gitlabjenkins/GitLabProjectBranchesService.java index b85e3cb..a7ab0bb 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/GitLabProjectBranchesService.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/GitLabProjectBranchesService.java @@ -20,9 +20,8 @@ public class GitLabProjectBranchesService { private static final Logger LOGGER = Logger.getLogger(GitLabProjectBranchesService.class.getName()); - private final Cache> projectBranchCache; - private static transient GitLabProjectBranchesService gitLabProjectBranchesService; + private final Cache> projectBranchCache; GitLabProjectBranchesService() { this.projectBranchCache = CacheBuilder.newBuilder() diff --git a/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java b/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java index 694d185..5c94da2 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java @@ -96,12 +96,42 @@ public class GitLabPushTrigger extends Trigger> { initializeBranchFilter(); } + @Initializer(after = InitMilestone.JOB_LOADED) + public static void migrateJobs() throws IOException { + GitLabPushTrigger.DescriptorImpl oldConfig = Trigger.all().get(GitLabPushTrigger.DescriptorImpl.class); + if (!oldConfig.jobsMigrated) { + GitLabConnectionConfig gitLabConfig = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class); + gitLabConfig.getConnections().add(new GitLabConnection(oldConfig.gitlabHostUrl, + oldConfig.gitlabHostUrl, + oldConfig.gitlabApiToken, + oldConfig.ignoreCertificateErrors)); + + String defaultConnectionName = gitLabConfig.getConnections().get(0).getName(); + for (AbstractProject project : Jenkins.getInstance().getAllItems(AbstractProject.class)) { + GitLabPushTrigger trigger = project.getTrigger(GitLabPushTrigger.class); + if (trigger != null) { + if (trigger.addCiMessage) { + project.getPublishersList().add(new GitLabCommitStatusPublisher()); + } + if (trigger.branchFilterType == null) { + trigger.branchFilterType = trigger.branchFilterName; + } + project.addProperty(new GitLabConnectionProperty(defaultConnectionName)); + project.save(); + } + } + gitLabConfig.save(); + oldConfig.jobsMigrated = true; + oldConfig.save(); + } + } + public boolean getTriggerOnPush() { - return triggerOnPush; + return triggerOnPush; } public boolean getTriggerOnMergeRequest() { - return triggerOnMergeRequest; + return triggerOnMergeRequest; } public TriggerOpenMergeRequest getTriggerOpenMergeRequestOnPush() { @@ -177,14 +207,14 @@ public class GitLabPushTrigger extends Trigger> { @Extension public static class DescriptorImpl extends TriggerDescriptor { + private transient final SequentialExecutionQueue queue = new SequentialExecutionQueue(Jenkins.MasterComputer.threadPoolForRemoting); private boolean jobsMigrated = false; private String gitlabApiToken; private String gitlabHostUrl = ""; private boolean ignoreCertificateErrors = false; - private transient final SequentialExecutionQueue queue = new SequentialExecutionQueue(Jenkins.MasterComputer.threadPoolForRemoting); public DescriptorImpl() { - load(); + load(); } @Override @@ -240,9 +270,9 @@ public class GitLabPushTrigger extends Trigger> { } public ListBoxModel doFillTriggerOpenMergeRequestOnPushItems(@QueryParameter String triggerOpenMergeRequestOnPush) { - return new ListBoxModel(new Option("Never", "never", triggerOpenMergeRequestOnPush.matches("never") ), - new Option("On push to source branch", "source", triggerOpenMergeRequestOnPush.matches("source") ), - new Option("On push to source or target branch", "both", triggerOpenMergeRequestOnPush.matches("both") )); + return new ListBoxModel(new Option("Never", "never", triggerOpenMergeRequestOnPush.matches("never")), + new Option("On push to source branch", "source", triggerOpenMergeRequestOnPush.matches("source")), + new Option("On push to source or target branch", "both", triggerOpenMergeRequestOnPush.matches("both"))); } public AutoCompletionCandidates doAutoCompleteIncludeBranchesSpec(@AncestorInPath final Job job, @QueryParameter final String value) { @@ -261,34 +291,4 @@ public class GitLabPushTrigger extends Trigger> { return ProjectBranchesProvider.instance().doCheckBranchesSpec(project, value); } } - - @Initializer(after = InitMilestone.JOB_LOADED) - public static void migrateJobs() throws IOException { - GitLabPushTrigger.DescriptorImpl oldConfig = Trigger.all().get(GitLabPushTrigger.DescriptorImpl.class); - if (!oldConfig.jobsMigrated) { - GitLabConnectionConfig gitLabConfig = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class); - gitLabConfig.getConnections().add(new GitLabConnection(oldConfig.gitlabHostUrl, - oldConfig.gitlabHostUrl, - oldConfig.gitlabApiToken, - oldConfig.ignoreCertificateErrors)); - - String defaultConnectionName = gitLabConfig.getConnections().get(0).getName(); - for (AbstractProject project : Jenkins.getInstance().getAllItems(AbstractProject.class)) { - GitLabPushTrigger trigger = project.getTrigger(GitLabPushTrigger.class); - if (trigger != null) { - if (trigger.addCiMessage) { - project.getPublishersList().add(new GitLabCommitStatusPublisher()); - } - if (trigger.branchFilterType == null) { - trigger.branchFilterType = trigger.branchFilterName; - } - project.addProperty(new GitLabConnectionProperty(defaultConnectionName)); - project.save(); - } - } - gitLabConfig.save(); - oldConfig.jobsMigrated = true; - oldConfig.save(); - } - } } diff --git a/src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java b/src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java index a0cbfbe..6d91924 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java @@ -8,7 +8,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; import java.util.HashMap; import java.util.Map; -import static com.google.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * @author Robin Müller @@ -258,7 +258,7 @@ public final class CauseData { }, MERGE { @Override String getShortDescription(CauseData data) { - return "GitLab Merge Request #" + data.getMergeRequestId()+ " : " + data.getSourceBranch() + " => " + data.getTargetBranch(); + return "GitLab Merge Request #" + data.getMergeRequestId() + " : " + data.getSourceBranch() + " => " + data.getTargetBranch(); } }; diff --git a/src/main/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfig.java b/src/main/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfig.java index 6e318ae..a13be3a 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfig.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfig.java @@ -11,7 +11,6 @@ import org.kohsuke.stapler.StaplerRequest; import javax.ws.rs.ProcessingException; import javax.ws.rs.WebApplicationException; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/dabsquared/gitlabjenkins/publisher/GitLabCommitStatusPublisher.java b/src/main/java/com/dabsquared/gitlabjenkins/publisher/GitLabCommitStatusPublisher.java index a0ecfee..62d78c3 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/publisher/GitLabCommitStatusPublisher.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/publisher/GitLabCommitStatusPublisher.java @@ -22,7 +22,6 @@ import org.kohsuke.stapler.DataBoundConstructor; import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; import java.io.IOException; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; diff --git a/src/main/java/com/dabsquared/gitlabjenkins/trigger/branch/AntPathMatcherSet.java b/src/main/java/com/dabsquared/gitlabjenkins/trigger/branch/AntPathMatcherSet.java index 94ff478..35e30d9 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/trigger/branch/AntPathMatcherSet.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/trigger/branch/AntPathMatcherSet.java @@ -10,12 +10,12 @@ import java.util.HashSet; */ class AntPathMatcherSet extends HashSet { + private transient final AntPathMatcher matcher = new AntPathMatcher(); + public AntPathMatcherSet(Collection c) { super(c); } - private transient final AntPathMatcher matcher = new AntPathMatcher(); - @Override public boolean contains(Object o) { for (String s : this) { diff --git a/src/main/java/com/dabsquared/gitlabjenkins/trigger/branch/ProjectBranchesProvider.java b/src/main/java/com/dabsquared/gitlabjenkins/trigger/branch/ProjectBranchesProvider.java index cc83079..c2d24cf 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/trigger/branch/ProjectBranchesProvider.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/trigger/branch/ProjectBranchesProvider.java @@ -5,10 +5,6 @@ import com.dabsquared.gitlabjenkins.Messages; import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty; import com.google.common.base.Joiner; import com.google.common.base.Splitter; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Lists; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; import hudson.model.AutoCompletionCandidates; import hudson.model.Item; import hudson.model.Job; @@ -23,7 +19,6 @@ import org.eclipse.jgit.transport.URIish; import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.QueryParameter; -import java.io.IOException; import java.util.Collections; import java.util.HashSet; import java.util.List; diff --git a/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/push/OpenMergeRequestPushHookTriggerHandler.java b/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/push/OpenMergeRequestPushHookTriggerHandler.java index 995e39e..b3fff2f 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/push/OpenMergeRequestPushHookTriggerHandler.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/push/OpenMergeRequestPushHookTriggerHandler.java @@ -47,7 +47,7 @@ class OpenMergeRequestPushHookTriggerHandler implements PushHookTriggerHandler { if (property != null && property.getClient() != null && projectId != null && trigger != null) { GitLabApi client = property.getClient(); for (MergeRequest mergeRequest : getOpenMergeRequests(client, projectId.toString())) { - handleMergeRequest(job, hook, ciSkip, branchFilter, client, projectId, mergeRequest); + handleMergeRequest(job, hook, ciSkip, branchFilter, client, projectId, mergeRequest); } } } diff --git a/src/main/java/com/dabsquared/gitlabjenkins/webhook/ActionResolver.java b/src/main/java/com/dabsquared/gitlabjenkins/webhook/ActionResolver.java index 03b3c4f..a200cd4 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/webhook/ActionResolver.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/webhook/ActionResolver.java @@ -1,7 +1,6 @@ package com.dabsquared.gitlabjenkins.webhook; import com.dabsquared.gitlabjenkins.util.ACLUtil; -import com.dabsquared.gitlabjenkins.util.LoggerUtil; import com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction; import com.dabsquared.gitlabjenkins.webhook.build.PushBuildAction; import com.dabsquared.gitlabjenkins.webhook.status.BranchBuildPageRedirectAction; diff --git a/src/main/java/com/dabsquared/gitlabjenkins/webhook/GitLabWebHook.java b/src/main/java/com/dabsquared/gitlabjenkins/webhook/GitLabWebHook.java index 15b9f2f..a9558fa 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/webhook/GitLabWebHook.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/webhook/GitLabWebHook.java @@ -15,17 +15,16 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * * @author Daniel Brooks */ @Extension public class GitLabWebHook implements UnprotectedRootAction { - private static final Logger LOGGER = Logger.getLogger(GitLabWebHook.class.getName()); - public static final String WEBHOOK_URL = "project"; + private static final Logger LOGGER = Logger.getLogger(GitLabWebHook.class.getName()); + private transient final ActionResolver actionResolver = new ActionResolver(); public String getIconFileName() { diff --git a/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/BuildPageRedirectAction.java b/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/BuildPageRedirectAction.java index 31a9e8c..7eac6a7 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/BuildPageRedirectAction.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/BuildPageRedirectAction.java @@ -1,8 +1,6 @@ package com.dabsquared.gitlabjenkins.webhook.status; import com.dabsquared.gitlabjenkins.webhook.WebHookAction; -import hudson.model.AbstractBuild; -import hudson.model.Job; import hudson.model.Run; import hudson.util.HttpResponses; import jenkins.model.Jenkins; @@ -22,7 +20,7 @@ abstract class BuildPageRedirectAction implements WebHookAction { } public void execute(StaplerResponse response) { - if(build != null) { + if (build != null) { try { response.sendRedirect2(Jenkins.getInstance().getRootUrl() + build.getUrl()); } catch (IOException e) { diff --git a/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/BuildStatusAction.java b/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/BuildStatusAction.java index 1a72597..d3996c2 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/BuildStatusAction.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/BuildStatusAction.java @@ -34,9 +34,9 @@ abstract class BuildStatusAction implements WebHookAction { protected abstract void writeStatusBody(StaplerResponse response, Run build, BuildStatus status); private boolean hasGitSCM(SCMTriggerItem item) { - if(item != null) { - for(SCM scm : item.getSCMs()) { - if(scm instanceof GitSCM) { + if (item != null) { + for (SCM scm : item.getSCMs()) { + if (scm instanceof GitSCM) { return true; } } diff --git a/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/CommitBuildPageRedirectAction.java b/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/CommitBuildPageRedirectAction.java index 8863015..bf0f1a5 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/CommitBuildPageRedirectAction.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/CommitBuildPageRedirectAction.java @@ -1,7 +1,6 @@ package com.dabsquared.gitlabjenkins.webhook.status; import com.dabsquared.gitlabjenkins.util.BuildUtil; -import hudson.model.AbstractProject; import hudson.model.Job; /** diff --git a/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/StatusPngAction.java b/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/StatusPngAction.java index fc5ab01..cffdd4a 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/StatusPngAction.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/webhook/status/StatusPngAction.java @@ -19,7 +19,7 @@ class StatusPngAction extends BuildStatusAction { @Override protected void writeStatusBody(StaplerResponse response, Run build, BuildStatus status) { try { - response.setHeader("Expires","Fri, 01 Jan 1984 00:00:00 GMT"); + response.setHeader("Expires", "Fri, 01 Jan 1984 00:00:00 GMT"); response.setHeader("Cache-Control", "no-cache, private"); response.setHeader("Content-Type", "image/png"); IOUtils.copy(getStatusImage(status), response.getOutputStream()); diff --git a/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/GitLabWebHookPollingAction/index.jelly b/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/GitLabWebHookPollingAction/index.jelly index b742e86..54f0324 100644 --- a/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/GitLabWebHookPollingAction/index.jelly +++ b/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/GitLabWebHookPollingAction/index.jelly @@ -22,23 +22,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> - + - +

${%Last GitLab Push}

- + ${%Polling has not run yet.}
-            
+            
             ${it.writeLogTo(output)}
           
-
\ No newline at end of file +
diff --git a/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/config.jelly b/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/config.jelly index dddd672..b81ad18 100644 --- a/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/config.jelly +++ b/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/config.jelly @@ -2,57 +2,57 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + +
+ + + + + + + + + + - - - - - - -
-
+ + + + + + + +
diff --git a/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/help.jelly b/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/help.jelly index ef15248..a0589ab 100644 --- a/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/help.jelly +++ b/src/main/resources/com/dabsquared/gitlabjenkins/GitLabPushTrigger/help.jelly @@ -1,4 +1,4 @@
- Configure GitLab to deliver a POST request to your Jenkins instance like GitLab CI. -
\ No newline at end of file + Configure GitLab to deliver a POST request to your Jenkins instance like GitLab CI. + diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly index 3b7eb26..1e1f783 100644 --- a/src/main/resources/index.jelly +++ b/src/main/resources/index.jelly @@ -1,4 +1,6 @@
- This plugin integrates GitLab to Jenkins by faking a GitLab CI Server. -
\ No newline at end of file + This plugin integrates + GitLab + to Jenkins by faking a GitLab CI Server. + diff --git a/src/main/webapp/help/help-allowedBranches.html b/src/main/webapp/help/help-allowedBranches.html index 2f0d469..e9d2976 100644 --- a/src/main/webapp/help/help-allowedBranches.html +++ b/src/main/webapp/help/help-allowedBranches.html @@ -1,4 +1,5 @@ -

Comma-separated list of source branches allowed to trigger a build from a Push event or a Merge Request event. - If both fields are left empty, all branches are allowed to trigger this job. - For Merge Request events only the target branch name is filtered out by the include and exclude lists. - \ No newline at end of file +

+ Comma-separated list of source branches allowed to trigger a build from a Push event or a Merge Request event. + If both fields are left empty, all branches are allowed to trigger this job. + For Merge Request events only the target branch name is filtered out by the include and exclude lists. +

diff --git a/src/main/webapp/help/help-filterBranchesByRegex.html b/src/main/webapp/help/help-filterBranchesByRegex.html index 99587c3..498f7a2 100644 --- a/src/main/webapp/help/help-filterBranchesByRegex.html +++ b/src/main/webapp/help/help-filterBranchesByRegex.html @@ -1,9 +1,9 @@
-
-

The target branch regex allows to limit the execution of this job to certain branches. Any branch matching the specified pattern triggers the - job. No filtering is performed if the field is left empty.

-

Examples:

-
# Allow execution for debug and release branches: (.*debug.*|.*release.*) 
-
# Ignore any branch with `Release` or `release` as subword: ^(?:(?![R|r]elease).)*$ 
-
-
\ No newline at end of file +
+

The target branch regex allows to limit the execution of this job to certain branches. Any branch matching the specified pattern triggers + the job. No filtering is performed if the field is left empty.

+

Examples:

+
# Allow execution for debug and release branches: (.*debug.*|.*release.*) 
+
# Ignore any branch with `Release` or `release` as subword: ^(?:(?![R|r]elease).)*$ 
+
+ diff --git a/src/main/webapp/help/help-gitlab8.1CI.html b/src/main/webapp/help/help-gitlab8.1CI.html index c6d0371..ab96579 100644 --- a/src/main/webapp/help/help-gitlab8.1CI.html +++ b/src/main/webapp/help/help-gitlab8.1CI.html @@ -1,3 +1,3 @@
- Enable GitLab 8.1 Continuous Integration feature. DO NOT ENABLE IF YOU'RE USING A VERSION BEFORE GITLAB 8.1. -
\ No newline at end of file + Enable GitLab 8.1 Continuous Integration feature. DO NOT ENABLE IF YOU'RE USING A VERSION BEFORE GITLAB 8.1. + diff --git a/src/main/webapp/help/help-noBranchFiltering.html b/src/main/webapp/help/help-noBranchFiltering.html index 87202e7..a442c0d 100644 --- a/src/main/webapp/help/help-noBranchFiltering.html +++ b/src/main/webapp/help/help-noBranchFiltering.html @@ -1,3 +1,3 @@
-

All branches are allowed to trigger this job.

-
\ No newline at end of file +

All branches are allowed to trigger this job.

+ diff --git a/src/test/java/com/dabsquared/gitlabjenkins/GitLabProjectBranchesServiceTest.java b/src/test/java/com/dabsquared/gitlabjenkins/GitLabProjectBranchesServiceTest.java index fe2d6f3..e7d250a 100644 --- a/src/test/java/com/dabsquared/gitlabjenkins/GitLabProjectBranchesServiceTest.java +++ b/src/test/java/com/dabsquared/gitlabjenkins/GitLabProjectBranchesServiceTest.java @@ -23,13 +23,13 @@ import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class GitLabProjectBranchesServiceTest { + private final static List BRANCH_NAMES_PROJECT_B = asList("master", "B-branch-1", "B-branch-2"); + private GitLabProjectBranchesService branchesService; @Mock private GitLabApi gitlabApi; - private final static List BRANCH_NAMES_PROJECT_B = asList("master", "B-branch-1", "B-branch-2"); - @Before public void setUp() throws IOException { List branchNamesProjectA = convert(asList("master", "A-branch-1")); diff --git a/src/test/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfigSSLTest.java b/src/test/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfigSSLTest.java index 8a011d7..a2fbf92 100644 --- a/src/test/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfigSSLTest.java +++ b/src/test/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfigSSLTest.java @@ -28,12 +28,12 @@ import static org.junit.Assert.assertThat; */ public class GitLabConnectionConfigSSLTest { - @Rule - public JenkinsRule jenkins = new JenkinsRule(); - private static int port; private static Server server; + @Rule + public JenkinsRule jenkins = new JenkinsRule(); + @BeforeClass public static void startJetty() throws Exception { port = PortFactory.findFreePort(); @@ -42,7 +42,7 @@ public class GitLabConnectionConfigSSLTest { sslSocketConnector.setKeystore("src/test/resources/keystore"); sslSocketConnector.setKeyPassword("password"); sslSocketConnector.setPort(port); - server.setConnectors(new Connector[] {sslSocketConnector}); + server.setConnectors(new Connector[]{sslSocketConnector}); server.addHandler(new AbstractHandler() { public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { response.setStatus(Response.Status.OK.getStatusCode()); diff --git a/src/test/java/com/dabsquared/gitlabjenkins/publisher/GitLabCommitStatusPublisherTest.java b/src/test/java/com/dabsquared/gitlabjenkins/publisher/GitLabCommitStatusPublisherTest.java index 7e3da5d..de8e815 100644 --- a/src/test/java/com/dabsquared/gitlabjenkins/publisher/GitLabCommitStatusPublisherTest.java +++ b/src/test/java/com/dabsquared/gitlabjenkins/publisher/GitLabCommitStatusPublisherTest.java @@ -1,8 +1,8 @@ package com.dabsquared.gitlabjenkins.publisher; -import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty; import com.dabsquared.gitlabjenkins.connection.GitLabConnection; import com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig; +import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty; import com.dabsquared.gitlabjenkins.gitlab.api.model.BuildState; import hudson.model.AbstractBuild; import hudson.model.AbstractProject; @@ -175,12 +175,12 @@ public class GitLabCommitStatusPublisherTest { private HttpRequest prepareUpdateCommitStatus(String projectId, String sha, String targetUrl, BuildState state) throws UnsupportedEncodingException { return request() - .withPath("/gitlab/api/v3/projects/" + URLEncoder.encode(projectId, "UTF-8") + "/statuses/" + sha) - .withMethod("POST") - .withHeader("PRIVATE-TOKEN", "secret") - .withQueryStringParameter("state", state.name()) - .withQueryStringParameter("context", "jenkins") - .withQueryStringParameter("target_url", targetUrl); + .withPath("/gitlab/api/v3/projects/" + URLEncoder.encode(projectId, "UTF-8") + "/statuses/" + sha) + .withMethod("POST") + .withHeader("PRIVATE-TOKEN", "secret") + .withQueryStringParameter("state", state.name()) + .withQueryStringParameter("context", "jenkins") + .withQueryStringParameter("target_url", targetUrl); } private HttpRequest prepareExistsCommitWithSuccessResponse(String projectId, String sha) throws UnsupportedEncodingException { @@ -191,9 +191,9 @@ public class GitLabCommitStatusPublisherTest { private HttpRequest prepareExistsCommit(String projectId, String sha) throws UnsupportedEncodingException { return request() - .withPath("/gitlab/api/v3/projects/" + URLEncoder.encode(projectId, "UTF-8") + "/repository/commits/" + sha) - .withMethod("HEAD") - .withHeader("PRIVATE-TOKEN", "secret"); + .withPath("/gitlab/api/v3/projects/" + URLEncoder.encode(projectId, "UTF-8") + "/repository/commits/" + sha) + .withMethod("HEAD") + .withHeader("PRIVATE-TOKEN", "secret"); } private AbstractBuild mockBuild(String sha, String buildUrl, String gitLabConnection, Result result, String... remoteUrls) { diff --git a/src/test/java/com/dabsquared/gitlabjenkins/testhelpers/GitLabPushRequestSamples.java b/src/test/java/com/dabsquared/gitlabjenkins/testhelpers/GitLabPushRequestSamples.java index 62c29e6..f646468 100644 --- a/src/test/java/com/dabsquared/gitlabjenkins/testhelpers/GitLabPushRequestSamples.java +++ b/src/test/java/com/dabsquared/gitlabjenkins/testhelpers/GitLabPushRequestSamples.java @@ -3,15 +3,15 @@ package com.dabsquared.gitlabjenkins.testhelpers; import com.dabsquared.gitlabjenkins.gitlab.hook.model.PushHook; public interface GitLabPushRequestSamples { - PushHook pushBrandNewMasterBranchRequest(); + PushHook pushBrandNewMasterBranchRequest(); - PushHook pushNewBranchRequest(); + PushHook pushNewBranchRequest(); - PushHook pushCommitRequest(); + PushHook pushCommitRequest(); - PushHook mergePushRequest(); + PushHook mergePushRequest(); - PushHook pushNewTagRequest(); + PushHook pushNewTagRequest(); - PushHook deleteBranchRequest(); + PushHook deleteBranchRequest(); } diff --git a/src/test/java/com/dabsquared/gitlabjenkins/trigger/handler/push/PushHookTriggerHandlerGitlabServerTest.java b/src/test/java/com/dabsquared/gitlabjenkins/trigger/handler/push/PushHookTriggerHandlerGitlabServerTest.java index 8cd203f..046c5b4 100644 --- a/src/test/java/com/dabsquared/gitlabjenkins/trigger/handler/push/PushHookTriggerHandlerGitlabServerTest.java +++ b/src/test/java/com/dabsquared/gitlabjenkins/trigger/handler/push/PushHookTriggerHandlerGitlabServerTest.java @@ -1,23 +1,14 @@ package com.dabsquared.gitlabjenkins.trigger.handler.push; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - import com.dabsquared.gitlabjenkins.gitlab.hook.model.PushHook; +import com.dabsquared.gitlabjenkins.testhelpers.GitLabPushRequestSamples; import com.dabsquared.gitlabjenkins.testhelpers.GitLabPushRequestSamples_7_10_5_489b413; import com.dabsquared.gitlabjenkins.testhelpers.GitLabPushRequestSamples_7_5_1_36679b5; import com.dabsquared.gitlabjenkins.testhelpers.GitLabPushRequestSamples_8_1_2_8c8af7b; import com.dabsquared.gitlabjenkins.trigger.exception.NoRevisionToBuildException; +import hudson.plugins.git.RevisionParameterAction; import org.eclipse.jgit.transport.RemoteConfig; import org.junit.Rule; - -import com.dabsquared.gitlabjenkins.testhelpers.GitLabPushRequestSamples; - -import hudson.plugins.git.RevisionParameterAction; import org.junit.experimental.theories.DataPoints; import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; @@ -26,6 +17,11 @@ import org.junit.runner.RunWith; import java.util.ArrayList; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; + @RunWith(Theories.class) public class PushHookTriggerHandlerGitlabServerTest { diff --git a/src/test/java/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest.java b/src/test/java/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest.java index 8b20965..19ea7c0 100644 --- a/src/test/java/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest.java +++ b/src/test/java/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest.java @@ -139,7 +139,6 @@ public class ActionResolverTest { } - private static class ResourceServletInputStream extends ServletInputStream { private final InputStream input; diff --git a/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/BuildPageRedirectActionTest.java b/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/BuildPageRedirectActionTest.java index 70cc7cb..5e33cd5 100644 --- a/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/BuildPageRedirectActionTest.java +++ b/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/BuildPageRedirectActionTest.java @@ -33,13 +33,11 @@ public abstract class BuildPageRedirectActionTest { @Rule public TemporaryFolder tmp = new TemporaryFolder(); - - @Mock - private StaplerResponse response; - - private String gitRepoUrl; protected String commitSha1; protected String branch = "master"; + @Mock + private StaplerResponse response; + private String gitRepoUrl; @Before public void setup() throws Exception { diff --git a/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/BuildStatusActionTest.java b/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/BuildStatusActionTest.java index 2bde158..11af11d 100644 --- a/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/BuildStatusActionTest.java +++ b/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/BuildStatusActionTest.java @@ -6,9 +6,7 @@ import hudson.model.BuildListener; import hudson.model.FreeStyleBuild; import hudson.model.FreeStyleProject; import hudson.model.Result; -import hudson.model.queue.QueueTaskFuture; import hudson.plugins.git.GitSCM; -import hudson.tasks.Shell; import hudson.util.OneShotEvent; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.revwalk.RevCommit; @@ -44,12 +42,13 @@ public abstract class BuildStatusActionTest { @Rule public TemporaryFolder tmp = new TemporaryFolder(); + protected String commitSha1; + protected String branch = "master"; + @Mock private StaplerResponse response; private String gitRepoUrl; - protected String commitSha1; - protected String branch = "master"; @Before public void setup() throws Exception { diff --git a/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/StatusPngActionTest.java b/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/StatusPngActionTest.java index 2e14599..9019e68 100644 --- a/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/StatusPngActionTest.java +++ b/src/test/java/com/dabsquared/gitlabjenkins/webhook/status/StatusPngActionTest.java @@ -18,7 +18,7 @@ public abstract class StatusPngActionTest extends BuildStatusActionTest { @Override protected void assertSuccessfulBuild(FreeStyleBuild build, ByteArrayOutputStream out, StaplerResponse response) throws IOException { - verify(response).setHeader("Expires","Fri, 01 Jan 1984 00:00:00 GMT"); + verify(response).setHeader("Expires", "Fri, 01 Jan 1984 00:00:00 GMT"); verify(response).setHeader("Cache-Control", "no-cache, private"); verify(response).setHeader("Content-Type", "image/png"); assertThat(out.toByteArray(), is(IOUtils.toByteArray(getClass().getResourceAsStream("success.png")))); @@ -26,7 +26,7 @@ public abstract class StatusPngActionTest extends BuildStatusActionTest { @Override protected void assertFailedBuild(FreeStyleBuild build, ByteArrayOutputStream out, StaplerResponse response) throws IOException { - verify(response).setHeader("Expires","Fri, 01 Jan 1984 00:00:00 GMT"); + verify(response).setHeader("Expires", "Fri, 01 Jan 1984 00:00:00 GMT"); verify(response).setHeader("Cache-Control", "no-cache, private"); verify(response).setHeader("Content-Type", "image/png"); assertThat(out.toByteArray(), is(IOUtils.toByteArray(getClass().getResourceAsStream("failed.png")))); @@ -34,7 +34,7 @@ public abstract class StatusPngActionTest extends BuildStatusActionTest { @Override protected void assertRunningBuild(FreeStyleBuild build, ByteArrayOutputStream out, StaplerResponse response) throws IOException { - verify(response).setHeader("Expires","Fri, 01 Jan 1984 00:00:00 GMT"); + verify(response).setHeader("Expires", "Fri, 01 Jan 1984 00:00:00 GMT"); verify(response).setHeader("Cache-Control", "no-cache, private"); verify(response).setHeader("Content-Type", "image/png"); assertThat(out.toByteArray(), is(IOUtils.toByteArray(getClass().getResourceAsStream("running.png")))); @@ -42,7 +42,7 @@ public abstract class StatusPngActionTest extends BuildStatusActionTest { @Override protected void assertCanceledBuild(FreeStyleBuild build, ByteArrayOutputStream out, StaplerResponse response) throws IOException { - verify(response).setHeader("Expires","Fri, 01 Jan 1984 00:00:00 GMT"); + verify(response).setHeader("Expires", "Fri, 01 Jan 1984 00:00:00 GMT"); verify(response).setHeader("Cache-Control", "no-cache, private"); verify(response).setHeader("Content-Type", "image/png"); assertThat(out.toByteArray(), is(IOUtils.toByteArray(getClass().getResourceAsStream("unknown.png")))); @@ -50,7 +50,7 @@ public abstract class StatusPngActionTest extends BuildStatusActionTest { @Override protected void assertUnstableBuild(FreeStyleBuild build, ByteArrayOutputStream out, StaplerResponse response) throws IOException { - verify(response).setHeader("Expires","Fri, 01 Jan 1984 00:00:00 GMT"); + verify(response).setHeader("Expires", "Fri, 01 Jan 1984 00:00:00 GMT"); verify(response).setHeader("Cache-Control", "no-cache, private"); verify(response).setHeader("Content-Type", "image/png"); assertThat(out.toByteArray(), is(IOUtils.toByteArray(getClass().getResourceAsStream("unstable.png")))); @@ -58,7 +58,7 @@ public abstract class StatusPngActionTest extends BuildStatusActionTest { @Override protected void assertNotFoundBuild(ByteArrayOutputStream out, StaplerResponse response) throws IOException { - verify(response).setHeader("Expires","Fri, 01 Jan 1984 00:00:00 GMT"); + verify(response).setHeader("Expires", "Fri, 01 Jan 1984 00:00:00 GMT"); verify(response).setHeader("Cache-Control", "no-cache, private"); verify(response).setHeader("Content-Type", "image/png"); assertThat(out.toByteArray(), is(IOUtils.toByteArray(getClass().getResourceAsStream("unknown.png")))); diff --git a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest_postMergeRequest.json b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest_postMergeRequest.json index ebf9e73..94d8bb0 100644 --- a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest_postMergeRequest.json +++ b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest_postMergeRequest.json @@ -23,37 +23,37 @@ "target_project_id": 14, "iid": 1, "description": "", - "source":{ - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "source": { + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "target": { - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "last_commit": { "id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", diff --git a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest_postPush.json b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest_postPush.json index 9fde0fb..0c741ea 100644 --- a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest_postPush.json +++ b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest_postPush.json @@ -8,30 +8,30 @@ "user_email": "john@example.com", "user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80", "project_id": 15, - "project":{ - "name":"Diaspora", - "description":"", - "web_url":"http://example.com/mike/diaspora", - "avatar_url":null, - "git_ssh_url":"git@example.com:mike/diaspora.git", - "git_http_url":"http://example.com/mike/diaspora.git", - "namespace":"Mike", - "visibility_level":0, - "path_with_namespace":"mike/diaspora", - "default_branch":"master", - "homepage":"http://example.com/mike/diaspora", - "url":"git@example.com:mike/diasporadiaspora.git", - "ssh_url":"git@example.com:mike/diaspora.git", - "http_url":"http://example.com/mike/diaspora.git" + "project": { + "name": "Diaspora", + "description": "", + "web_url": "http://example.com/mike/diaspora", + "avatar_url": null, + "git_ssh_url": "git@example.com:mike/diaspora.git", + "git_http_url": "http://example.com/mike/diaspora.git", + "namespace": "Mike", + "visibility_level": 0, + "path_with_namespace": "mike/diaspora", + "default_branch": "master", + "homepage": "http://example.com/mike/diaspora", + "url": "git@example.com:mike/diasporadiaspora.git", + "ssh_url": "git@example.com:mike/diaspora.git", + "http_url": "http://example.com/mike/diaspora.git" }, - "repository":{ + "repository": { "name": "Diaspora", "url": "git@example.com:mike/diasporadiaspora.git", "description": "", "homepage": "http://example.com/mike/diaspora", - "git_http_url":"http://example.com/mike/diaspora.git", - "git_ssh_url":"git@example.com:mike/diaspora.git", - "visibility_level":0 + "git_http_url": "http://example.com/mike/diaspora.git", + "git_ssh_url": "git@example.com:mike/diaspora.git", + "visibility_level": 0 }, "commits": [ { @@ -43,8 +43,12 @@ "name": "Jordi Mallach", "email": "jordi@softcatala.org" }, - "added": ["CHANGELOG"], - "modified": ["app/controller/application.rb"], + "added": [ + "CHANGELOG" + ], + "modified": [ + "app/controller/application.rb" + ], "removed": [] }, { @@ -56,8 +60,12 @@ "name": "GitLab dev user", "email": "gitlabdev@dv6700.(none)" }, - "added": ["CHANGELOG"], - "modified": ["app/controller/application.rb"], + "added": [ + "CHANGELOG" + ], + "modified": [ + "app/controller/application.rb" + ], "removed": [] } ], diff --git a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent.json b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent.json index ebf9e73..94d8bb0 100644 --- a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent.json +++ b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent.json @@ -23,37 +23,37 @@ "target_project_id": 14, "iid": 1, "description": "", - "source":{ - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "source": { + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "target": { - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "last_commit": { "id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", diff --git a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_alreadyBuiltMR.json b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_alreadyBuiltMR.json index 5d8810e..d9fc119 100644 --- a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_alreadyBuiltMR.json +++ b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_alreadyBuiltMR.json @@ -23,37 +23,37 @@ "target_project_id": 14, "iid": 1, "description": "", - "source":{ - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "source": { + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "target": { - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "last_commit": { "id": "${commitSha1}", diff --git a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_alreadyBuiltMR_differentTargetBranch.json b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_alreadyBuiltMR_differentTargetBranch.json index 4415335..01234a6 100644 --- a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_alreadyBuiltMR_differentTargetBranch.json +++ b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_alreadyBuiltMR_differentTargetBranch.json @@ -23,37 +23,37 @@ "target_project_id": 14, "iid": 1, "description": "", - "source":{ - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "source": { + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "target": { - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "last_commit": { "id": "${commitSha1}", diff --git a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_closedMR.json b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_closedMR.json index d6f22c0..0923126 100644 --- a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_closedMR.json +++ b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/MergeRequestEvent_closedMR.json @@ -23,37 +23,37 @@ "target_project_id": 14, "iid": 1, "description": "", - "source":{ - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "source": { + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "target": { - "name":"Awesome Project", - "description":"Aut reprehenderit ut est.", - "web_url":"http://example.com/awesome_space/awesome_project", - "avatar_url":null, - "git_ssh_url":"git@example.com:awesome_space/awesome_project.git", - "git_http_url":"http://example.com/awesome_space/awesome_project.git", - "namespace":"Awesome Space", - "visibility_level":20, - "path_with_namespace":"awesome_space/awesome_project", - "default_branch":"master", - "homepage":"http://example.com/awesome_space/awesome_project", - "url":"http://example.com/awesome_space/awesome_project.git", - "ssh_url":"git@example.com:awesome_space/awesome_project.git", - "http_url":"http://example.com/awesome_space/awesome_project.git" + "name": "Awesome Project", + "description": "Aut reprehenderit ut est.", + "web_url": "http://example.com/awesome_space/awesome_project", + "avatar_url": null, + "git_ssh_url": "git@example.com:awesome_space/awesome_project.git", + "git_http_url": "http://example.com/awesome_space/awesome_project.git", + "namespace": "Awesome Space", + "visibility_level": 20, + "path_with_namespace": "awesome_space/awesome_project", + "default_branch": "master", + "homepage": "http://example.com/awesome_space/awesome_project", + "url": "http://example.com/awesome_space/awesome_project.git", + "ssh_url": "git@example.com:awesome_space/awesome_project.git", + "http_url": "http://example.com/awesome_space/awesome_project.git" }, "last_commit": { "id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", diff --git a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/PushEvent.json b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/PushEvent.json index 9fde0fb..0c741ea 100644 --- a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/PushEvent.json +++ b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/PushEvent.json @@ -8,30 +8,30 @@ "user_email": "john@example.com", "user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80", "project_id": 15, - "project":{ - "name":"Diaspora", - "description":"", - "web_url":"http://example.com/mike/diaspora", - "avatar_url":null, - "git_ssh_url":"git@example.com:mike/diaspora.git", - "git_http_url":"http://example.com/mike/diaspora.git", - "namespace":"Mike", - "visibility_level":0, - "path_with_namespace":"mike/diaspora", - "default_branch":"master", - "homepage":"http://example.com/mike/diaspora", - "url":"git@example.com:mike/diasporadiaspora.git", - "ssh_url":"git@example.com:mike/diaspora.git", - "http_url":"http://example.com/mike/diaspora.git" + "project": { + "name": "Diaspora", + "description": "", + "web_url": "http://example.com/mike/diaspora", + "avatar_url": null, + "git_ssh_url": "git@example.com:mike/diaspora.git", + "git_http_url": "http://example.com/mike/diaspora.git", + "namespace": "Mike", + "visibility_level": 0, + "path_with_namespace": "mike/diaspora", + "default_branch": "master", + "homepage": "http://example.com/mike/diaspora", + "url": "git@example.com:mike/diasporadiaspora.git", + "ssh_url": "git@example.com:mike/diaspora.git", + "http_url": "http://example.com/mike/diaspora.git" }, - "repository":{ + "repository": { "name": "Diaspora", "url": "git@example.com:mike/diasporadiaspora.git", "description": "", "homepage": "http://example.com/mike/diaspora", - "git_http_url":"http://example.com/mike/diaspora.git", - "git_ssh_url":"git@example.com:mike/diaspora.git", - "visibility_level":0 + "git_http_url": "http://example.com/mike/diaspora.git", + "git_ssh_url": "git@example.com:mike/diaspora.git", + "visibility_level": 0 }, "commits": [ { @@ -43,8 +43,12 @@ "name": "Jordi Mallach", "email": "jordi@softcatala.org" }, - "added": ["CHANGELOG"], - "modified": ["app/controller/application.rb"], + "added": [ + "CHANGELOG" + ], + "modified": [ + "app/controller/application.rb" + ], "removed": [] }, { @@ -56,8 +60,12 @@ "name": "GitLab dev user", "email": "gitlabdev@dv6700.(none)" }, - "added": ["CHANGELOG"], - "modified": ["app/controller/application.rb"], + "added": [ + "CHANGELOG" + ], + "modified": [ + "app/controller/application.rb" + ], "removed": [] } ], diff --git a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/PushEvent_missingRepositoryUrl.json b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/PushEvent_missingRepositoryUrl.json index 1d9e570..ddf9a77 100644 --- a/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/PushEvent_missingRepositoryUrl.json +++ b/src/test/resources/com/dabsquared/gitlabjenkins/webhook/build/PushEvent_missingRepositoryUrl.json @@ -8,29 +8,29 @@ "user_email": "john@example.com", "user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80", "project_id": 15, - "project":{ - "name":"Diaspora", - "description":"", - "web_url":"http://example.com/mike/diaspora", - "avatar_url":null, - "git_ssh_url":"git@example.com:mike/diaspora.git", - "git_http_url":"http://example.com/mike/diaspora.git", - "namespace":"Mike", - "visibility_level":0, - "path_with_namespace":"mike/diaspora", - "default_branch":"master", - "homepage":"http://example.com/mike/diaspora", - "url":"git@example.com:mike/diasporadiaspora.git", - "ssh_url":"git@example.com:mike/diaspora.git", - "http_url":"http://example.com/mike/diaspora.git" + "project": { + "name": "Diaspora", + "description": "", + "web_url": "http://example.com/mike/diaspora", + "avatar_url": null, + "git_ssh_url": "git@example.com:mike/diaspora.git", + "git_http_url": "http://example.com/mike/diaspora.git", + "namespace": "Mike", + "visibility_level": 0, + "path_with_namespace": "mike/diaspora", + "default_branch": "master", + "homepage": "http://example.com/mike/diaspora", + "url": "git@example.com:mike/diasporadiaspora.git", + "ssh_url": "git@example.com:mike/diaspora.git", + "http_url": "http://example.com/mike/diaspora.git" }, - "repository":{ + "repository": { "name": "Diaspora", "description": "", "homepage": "http://example.com/mike/diaspora", - "git_http_url":"http://example.com/mike/diaspora.git", - "git_ssh_url":"git@example.com:mike/diaspora.git", - "visibility_level":0 + "git_http_url": "http://example.com/mike/diaspora.git", + "git_ssh_url": "git@example.com:mike/diaspora.git", + "visibility_level": 0 }, "commits": [ { @@ -42,8 +42,12 @@ "name": "Jordi Mallach", "email": "jordi@softcatala.org" }, - "added": ["CHANGELOG"], - "modified": ["app/controller/application.rb"], + "added": [ + "CHANGELOG" + ], + "modified": [ + "app/controller/application.rb" + ], "removed": [] }, { @@ -55,8 +59,12 @@ "name": "GitLab dev user", "email": "gitlabdev@dv6700.(none)" }, - "added": ["CHANGELOG"], - "modified": ["app/controller/application.rb"], + "added": [ + "CHANGELOG" + ], + "modified": [ + "app/controller/application.rb" + ], "removed": [] } ],