Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.0-beta-7</version>
<version>1.3</version>
</extension>
</extensions>
62 changes: 17 additions & 45 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.1</version>
<version>4.40</version>
<relativePath />
</parent>
<groupId>io.jenkins.plugins</groupId>
Expand All @@ -14,14 +14,11 @@
<properties>
<revision>1.5.10</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.263.4</jenkins.version>
<java.level>8</java.level>
<jcasc.version>1.36</jcasc.version>
<jenkins.version>2.289.3</jenkins.version>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
</properties>
<name>GitLab Branch Source Plugin</name>
<description>GitLab Provides branch source and folder organisation functionality for GitLab
Repositories in Jenkins Source Plugin
</description>
<description>GitLab Provides branch source and folder organisation functionality for GitLab Repositories in Jenkins Source Plugin</description>
<licenses>
<license>
<name>MIT License</name>
Expand Down Expand Up @@ -50,36 +47,18 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plain-credentials</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>handy-uri-templates-2-api</artifactId>
<version>2.1.6-1.0</version>
<version>2.1.8-1.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -120,13 +99,11 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-multibranch</artifactId>
<version>2.20</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>pipeline-stage-step</artifactId>
<version>2.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -139,22 +116,14 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-matchers</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins</groupId>
<artifactId>configuration-as-code</artifactId>
<version>${jcasc.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins.configuration-as-code</groupId>
<artifactId>test-harness</artifactId>
<version>${jcasc.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -165,6 +134,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -180,8 +153,8 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.176.x</artifactId>
<version>9</version>
<artifactId>bom-2.289.x</artifactId>
<version>1246.va_b_50630c1d19</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down Expand Up @@ -211,13 +184,12 @@
</developer>
</developers>

<url>https://github.com/jenkinsci/gitlab-branch-source-plugin</url>
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>

<scm>
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
</developerConnection>
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:git@github.com:${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
</scm>

Expand All @@ -227,12 +199,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.29</version>
<version>9.3</version>
</dependency>
</dependencies>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.plugins.gitlabbranchsource.Environment;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.EnvVars;
import hudson.Extension;
import hudson.model.EnvironmentContributor;
Expand All @@ -8,14 +9,13 @@
import io.jenkins.plugins.gitlabbranchsource.GitLabMergeRequestCommentCause;
import io.jenkins.plugins.gitlabbranchsource.GitLabWebHookCause;
import java.util.Map;
import javax.annotation.Nonnull;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;

@Extension
public class GitLabWebHookEnvironmentContributor extends EnvironmentContributor {

@Override
public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) {
public void buildEnvironmentFor(@NonNull Run r, @NonNull EnvVars envs, @NonNull TaskListener listener) {
GitLabWebHookCause gitLabWebHookCause = null;
GitLabMergeRequestCommentCause gitLabMergeRequestCommentCause = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.jenkins.plugins.gitlabbranchsource;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import javax.annotation.Nonnull;
import jenkins.scm.api.trait.SCMNavigatorContext;
import jenkins.scm.api.trait.SCMNavigatorTrait;
import jenkins.scm.api.trait.SCMNavigatorTraitDescriptor;
Expand Down Expand Up @@ -38,7 +38,7 @@ public Class<? extends SCMNavigatorContext> getContextClass() {
return GitLabSCMNavigatorContext.class;
}

@Nonnull
@NonNull
@Override
public String getDisplayName() {
return Messages.ExcludeArchivedRepositoriesTrait_displayName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import io.jenkins.plugins.gitlabbranchsource.helpers.GitLabBrowser;
import io.jenkins.plugins.gitlabserverconfig.servers.GitLabServer;
import java.net.URI;
import java.security.SecureRandom;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import jenkins.plugins.git.GitSCMBuilder;
import jenkins.plugins.git.MergeWithGitSCMExtension;
Expand All @@ -37,6 +37,8 @@
*/
public class GitLabSCMBuilder extends GitSCMBuilder<GitLabSCMBuilder> {

private static final SecureRandom RANDOM = new SecureRandom();

/**
* The context within which credentials should be resolved.
*/
Expand Down Expand Up @@ -243,13 +245,12 @@ public GitSCM build() {
}
if (localNames.contains(localName)) {
// ok we're just going to mangle our way to something that works
Random entropy = new Random();
while (localNames.contains(localName)) {
localName =
"remotes/" + remoteName() + "/merge-requests-" + head.getId()
+ "-upstream-" + name
+ "-" + Integer
.toHexString(entropy.nextInt(Integer.MAX_VALUE));
.toHexString(RANDOM.nextInt(Integer.MAX_VALUE));
}
}
withRefSpec("+refs/heads/" + name + ":refs/" + localName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.jenkins.plugins.gitlabserverconfig.action;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import hudson.Extension;
import hudson.model.RootAction;
import hudson.util.HttpResponses;
import io.jenkins.plugins.gitlabbranchsource.helpers.GitLabHelper;
import io.jenkins.plugins.gitlabserverconfig.servers.GitLabServers;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import jenkins.model.Jenkins;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class GitLabServer extends AbstractDescribableImpl<GitLabServer> {
*/
public final static String EMPTY_TOKEN = "";
private static final Logger LOGGER = Logger.getLogger(GitLabServer.class.getName());
private static final SecureRandom RANDOM = new SecureRandom();
/**
* Length of unique random numeric name for server
*/
Expand Down Expand Up @@ -267,7 +268,6 @@ public void setSecretToken(Secret token) {
// TODO: Use some UI element to trigger (what is the best way?)
private void generateSecretToken() {
byte[] random = new byte[16]; // 16x8=128bit worth of randomness, since we use md5 digest as the API token
SecureRandom RANDOM = new SecureRandom();
RANDOM.nextBytes(random);
this.secretToken = Secret.decrypt(Util.toHexString(random));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import org.junit.ClassRule;
import org.junit.Test;

import static com.jcabi.matchers.RegexMatchers.matchesPattern;
import static io.jenkins.plugins.casc.misc.Util.getUnclassifiedRoot;
import static io.jenkins.plugins.casc.misc.Util.toStringFromYamlFile;
import static io.jenkins.plugins.casc.misc.Util.toYamlString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.Matchers.not;

public class ConfigurationAsCodeTest {
Expand Down