gitlab rename to gitee
This commit is contained in:
parent
6dc5f9de2c
commit
8b8338b32b
|
@ -51,7 +51,7 @@ Version 1.2.0 of the plugin introduced improved logging for debugging purposes.
|
|||
1. Go to Jenkins -> Manage Jenkins -> System Log
|
||||
2. Add new log recorder
|
||||
3. Enter 'Gitlab plugin' or whatever you want for the name
|
||||
4. On the next page, enter 'com.dabsquared.gitlabjenkins' for Logger, set log level to FINEST, and save
|
||||
4. On the next page, enter 'com.dabsquared.giteejenkins' for Logger, set log level to FINEST, and save
|
||||
5. Then click on your Gitlab plugin log, click 'Clear this log' if necessary, and then use GitLab to trigger some actions
|
||||
6. Refresh the log page and you should see output
|
||||
|
||||
|
|
58
pom.xml
58
pom.xml
|
@ -13,10 +13,10 @@
|
|||
<findbugs.failOnError>false</findbugs.failOnError>
|
||||
</properties>
|
||||
|
||||
<artifactId>gitlab-plugin</artifactId>
|
||||
<artifactId>gitee-plugin</artifactId>
|
||||
<version>1.5.7-SNAPSHOT</version>
|
||||
<name>GitLab Plugin</name>
|
||||
<url>https://wiki.jenkins-ci.org/display/JENKINS/GitLab+Plugin</url>
|
||||
<name>Gitee Plugin</name>
|
||||
<!--<url>https://wiki.jenkins-ci.org/display/JENKINS/GitLab+Plugin</url>-->
|
||||
<packaging>hpi</packaging>
|
||||
|
||||
<licenses>
|
||||
|
@ -48,9 +48,9 @@
|
|||
</distributionManagement>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:ssh://github.com:jenkinsci/gitlab-plugin.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:jenkinsci/gitlab-plugin.git</developerConnection>
|
||||
<url>https://github.com/jenkinsci/gitlab-plugin</url>
|
||||
<connection>scm:git:ssh://gitee.com:yashin/Gitee-Plugin.git</connection>
|
||||
<developerConnection>scm:git:git@gitee.com:yashin/Gitee-Plugin.git</developerConnection>
|
||||
<url>https://gitee.com/yashin/Gitee-Plugin</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
<!-- get every artifact through repo.jenkins-ci.org, which proxies all the artifacts that we need -->
|
||||
|
@ -307,7 +307,7 @@
|
|||
<profile>
|
||||
<id>integration-test</id>
|
||||
<properties>
|
||||
<gitlab.version>8.17.4</gitlab.version>
|
||||
<gitee.version>8.17.4</gitee.version>
|
||||
<postgres.version>9.5-1</postgres.version>
|
||||
</properties>
|
||||
<build>
|
||||
|
@ -332,8 +332,8 @@
|
|||
<configuration>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>gitlab.http.port</name>
|
||||
<value>${gitlab.http.port}</value>
|
||||
<name>gitee.http.port</name>
|
||||
<value>${gitee.http.port}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>postgres.port</name>
|
||||
|
@ -357,10 +357,10 @@
|
|||
<configuration>
|
||||
<ports>
|
||||
<port>
|
||||
<name>gitlab.http.port</name>
|
||||
<name>gitee.http.port</name>
|
||||
</port>
|
||||
<port>
|
||||
<name>gitlab.ssh.port</name>
|
||||
<name>gitee.ssh.port</name>
|
||||
</port>
|
||||
<port>
|
||||
<name>postgres.port</name>
|
||||
|
@ -380,12 +380,12 @@
|
|||
<images>
|
||||
<image>
|
||||
<name>sameersbn/postgresql:${postgres.version}</name>
|
||||
<alias>it-gitlab-postgres</alias>
|
||||
<alias>it-gitee-postgres</alias>
|
||||
<run>
|
||||
<namingStrategy>alias</namingStrategy>
|
||||
<env>
|
||||
<DB_NAME>gitlabhq_production</DB_NAME>
|
||||
<DB_USER>gitlab</DB_USER>
|
||||
<DB_NAME>giteehq_production</DB_NAME>
|
||||
<DB_USER>gitee</DB_USER>
|
||||
<DB_PASS>password</DB_PASS>
|
||||
<DB_EXTENSION>pg_trgm</DB_EXTENSION>
|
||||
</env>
|
||||
|
@ -396,38 +396,38 @@
|
|||
</image>
|
||||
<image>
|
||||
<name>sameersbn/redis</name>
|
||||
<alias>it-gitlab-redis</alias>
|
||||
<alias>it-gitee-redis</alias>
|
||||
<run>
|
||||
<namingStrategy>alias</namingStrategy>
|
||||
</run>
|
||||
</image>
|
||||
<image>
|
||||
<name>sameersbn/gitlab:${gitlab.version}</name>
|
||||
<alias>it-gitlab-gitlab</alias>
|
||||
<name>sameersbn/gitee:${gitee.version}</name>
|
||||
<alias>it-gitee-gitee</alias>
|
||||
<run>
|
||||
<namingStrategy>alias</namingStrategy>
|
||||
<links>
|
||||
<link>it-gitlab-postgres:postgresql</link>
|
||||
<link>it-gitlab-redis:redisio</link>
|
||||
<link>it-gitee-postgres:postgresql</link>
|
||||
<link>it-gitee-redis:redisio</link>
|
||||
</links>
|
||||
<ports>
|
||||
<port>${gitlab.http.port}:80</port>
|
||||
<port>${gitlab.ssh.port}:22</port>
|
||||
<port>${gitee.http.port}:80</port>
|
||||
<port>${gitee.ssh.port}:22</port>
|
||||
</ports>
|
||||
<env>
|
||||
<DEBUG>false</DEBUG>
|
||||
<TZ>Asia/Kolkata</TZ>
|
||||
<GITLAB_TIMEZONE>Kolkata</GITLAB_TIMEZONE>
|
||||
<GITLAB_PORT>${gitlab.http.port}</GITLAB_PORT>
|
||||
<GITLAB_SSH_PORT>${gitlab.ssh.port}</GITLAB_SSH_PORT>
|
||||
<GITLAB_SECRETS_DB_KEY_BASE>long-and-random-alpha-numeric-string</GITLAB_SECRETS_DB_KEY_BASE>
|
||||
<GITLAB_SECRETS_SECRET_KEY_BASE>long-and-random-alphanumeric-string</GITLAB_SECRETS_SECRET_KEY_BASE>
|
||||
<GITLAB_SECRETS_OTP_KEY_BASE>long-and-random-alpha-numeric-string</GITLAB_SECRETS_OTP_KEY_BASE>
|
||||
<GITLAB_HOST>172.17.0.1</GITLAB_HOST>
|
||||
<GITEE_TIMEZONE>Kolkata</GITEE_TIMEZONE>
|
||||
<GITEE_PORT>${gitee.http.port}</GITEE_PORT>
|
||||
<GITEE_SSH_PORT>${gitee.ssh.port}</GITEE_SSH_PORT>
|
||||
<GITEE_SECRETS_DB_KEY_BASE>long-and-random-alpha-numeric-string</GITEE_SECRETS_DB_KEY_BASE>
|
||||
<GITEE_SECRETS_SECRET_KEY_BASE>long-and-random-alphanumeric-string</GITEE_SECRETS_SECRET_KEY_BASE>
|
||||
<GITEE_SECRETS_OTP_KEY_BASE>long-and-random-alpha-numeric-string</GITEE_SECRETS_OTP_KEY_BASE>
|
||||
<GITEE_HOST>172.17.0.1</GITEE_HOST>
|
||||
</env>
|
||||
<wait>
|
||||
<http>
|
||||
<url>http://localhost:${gitlab.http.port}/</url>
|
||||
<url>http://localhost:${gitee.http.port}/</url>
|
||||
</http>
|
||||
<time>120000</time>
|
||||
</wait>
|
||||
|
|
|
@ -7,16 +7,16 @@ services:
|
|||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- DB_USER=gitlab
|
||||
- DB_USER=gitee
|
||||
- DB_PASS=password
|
||||
- DB_NAME=gitlabhq_production
|
||||
- DB_EXTENSION=pg_trgm
|
||||
volumes:
|
||||
- /srv/docker/gitlab/postgresql:/var/lib/postgresql
|
||||
- /srv/docker/gitee/postgresql:/var/lib/postgresql
|
||||
|
||||
gitlab:
|
||||
restart: always
|
||||
image: sameersbn/gitlab:9.4.1
|
||||
image: sameersbn/gitee:9.4.1
|
||||
depends_on:
|
||||
- redis
|
||||
- postgresql
|
||||
|
@ -29,7 +29,7 @@ services:
|
|||
- DB_ADAPTER=postgresql
|
||||
- DB_HOST=postgresql
|
||||
- DB_PORT=5432
|
||||
- DB_USER=gitlab
|
||||
- DB_USER=gitee
|
||||
- DB_PASS=password
|
||||
- DB_NAME=gitlabhq_production
|
||||
|
||||
|
@ -80,13 +80,13 @@ services:
|
|||
- IMAP_SSL=true
|
||||
- IMAP_STARTTLS=false
|
||||
volumes:
|
||||
- /srv/docker/gitlab/gitlab:/home/git/data
|
||||
- /srv/docker/gitee/gitee:/home/git/data
|
||||
|
||||
redis:
|
||||
restart: always
|
||||
image: sameersbn/redis:latest
|
||||
volumes:
|
||||
- /srv/docker/gitlab/redis:/var/lib/redis
|
||||
- /srv/docker/gitee/redis:/var/lib/redis
|
||||
|
||||
jenkins:
|
||||
restart: always
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
package com.dabsquared.gitlabjenkins;
|
||||
package com.dabsquared.giteejenkins;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.connection.GitLabConnection;
|
||||
import com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig;
|
||||
import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestHook;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.NoteHook;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.PipelineHook;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.PushHook;
|
||||
import com.dabsquared.gitlabjenkins.publisher.GitLabAcceptMergeRequestPublisher;
|
||||
import com.dabsquared.gitlabjenkins.publisher.GitLabCommitStatusPublisher;
|
||||
import com.dabsquared.gitlabjenkins.publisher.GitLabMessagePublisher;
|
||||
import com.dabsquared.gitlabjenkins.publisher.GitLabVotePublisher;
|
||||
import com.dabsquared.gitlabjenkins.trigger.TriggerOpenMergeRequest;
|
||||
import com.dabsquared.gitlabjenkins.trigger.branch.ProjectBranchesProvider;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilterFactory;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilterType;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilterConfig;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilterFactory;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.merge.MergeRequestHookTriggerHandler;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.note.NoteHookTriggerHandler;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.pipeline.PipelineHookTriggerHandler;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.push.PushHookTriggerHandler;
|
||||
import com.dabsquared.gitlabjenkins.trigger.label.ProjectLabelsProvider;
|
||||
import com.dabsquared.gitlabjenkins.webhook.GitLabWebHook;
|
||||
import com.dabsquared.giteejenkins.connection.GiteeConnection;
|
||||
import com.dabsquared.giteejenkins.connection.GiteeConnectionConfig;
|
||||
import com.dabsquared.giteejenkins.connection.GiteeConnectionProperty;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.MergeRequestHook;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.NoteHook;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PipelineHook;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PushHook;
|
||||
import com.dabsquared.giteejenkins.publisher.GiteeAcceptMergeRequestPublisher;
|
||||
import com.dabsquared.giteejenkins.publisher.GiteeCommitStatusPublisher;
|
||||
import com.dabsquared.giteejenkins.publisher.GiteeMessagePublisher;
|
||||
import com.dabsquared.giteejenkins.publisher.GiteeVotePublisher;
|
||||
import com.dabsquared.giteejenkins.trigger.TriggerOpenMergeRequest;
|
||||
import com.dabsquared.giteejenkins.trigger.branch.ProjectBranchesProvider;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilterFactory;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilterType;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilterConfig;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilterFactory;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.merge.MergeRequestHookTriggerHandler;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.note.NoteHookTriggerHandler;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.pipeline.PipelineHookTriggerHandler;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.push.PushHookTriggerHandler;
|
||||
import com.dabsquared.giteejenkins.trigger.label.ProjectLabelsProvider;
|
||||
import com.dabsquared.giteejenkins.webhook.GiteeWebHook;
|
||||
import hudson.Extension;
|
||||
import hudson.Util;
|
||||
import hudson.init.InitMilestone;
|
||||
|
@ -61,19 +61,19 @@ import java.io.IOException;
|
|||
import java.io.ObjectStreamException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.trigger.filter.BranchFilterConfig.BranchFilterConfigBuilder.branchFilterConfig;
|
||||
import static com.dabsquared.gitlabjenkins.trigger.handler.merge.MergeRequestHookTriggerHandlerFactory.newMergeRequestHookTriggerHandler;
|
||||
import static com.dabsquared.gitlabjenkins.trigger.handler.note.NoteHookTriggerHandlerFactory.newNoteHookTriggerHandler;
|
||||
import static com.dabsquared.gitlabjenkins.trigger.handler.pipeline.PipelineHookTriggerHandlerFactory.newPipelineHookTriggerHandler;
|
||||
import static com.dabsquared.gitlabjenkins.trigger.handler.push.PushHookTriggerHandlerFactory.newPushHookTriggerHandler;
|
||||
import static com.dabsquared.giteejenkins.trigger.filter.BranchFilterConfig.BranchFilterConfigBuilder.branchFilterConfig;
|
||||
import static com.dabsquared.giteejenkins.trigger.handler.merge.MergeRequestHookTriggerHandlerFactory.newMergeRequestHookTriggerHandler;
|
||||
import static com.dabsquared.giteejenkins.trigger.handler.note.NoteHookTriggerHandlerFactory.newNoteHookTriggerHandler;
|
||||
import static com.dabsquared.giteejenkins.trigger.handler.pipeline.PipelineHookTriggerHandlerFactory.newPipelineHookTriggerHandler;
|
||||
import static com.dabsquared.giteejenkins.trigger.handler.push.PushHookTriggerHandlerFactory.newPushHookTriggerHandler;
|
||||
|
||||
|
||||
/**
|
||||
* Triggers a build when we receive a GitLab WebHook.
|
||||
* Triggers a build when we receive a Gitee WebHook.
|
||||
*
|
||||
* @author Daniel Brooks
|
||||
*/
|
||||
public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
|
||||
public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
|
||||
|
@ -112,18 +112,18 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
|
|||
private transient MergeRequestLabelFilter mergeRequestLabelFilter;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #GitLabPushTrigger()} with setters to configure an instance of this class.
|
||||
* @deprecated use {@link #GiteePushTrigger()} with setters to configure an instance of this class.
|
||||
*/
|
||||
@Deprecated
|
||||
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
||||
public GitLabPushTrigger(boolean triggerOnPush, boolean triggerOnMergeRequest, boolean triggerOnAcceptedMergeRequest, boolean triggerOnClosedMergeRequest,
|
||||
TriggerOpenMergeRequest triggerOpenMergeRequestOnPush, boolean triggerOnNoteRequest, String noteRegex,
|
||||
boolean skipWorkInProgressMergeRequest, boolean ciSkip,
|
||||
boolean setBuildDescription, boolean addNoteOnMergeRequest, boolean addCiMessage, boolean addVoteOnMergeRequest,
|
||||
boolean acceptMergeRequestOnSuccess, BranchFilterType branchFilterType,
|
||||
String includeBranchesSpec, String excludeBranchesSpec, String targetBranchRegex,
|
||||
MergeRequestLabelFilterConfig mergeRequestLabelFilterConfig, String secretToken, boolean triggerOnPipelineEvent,
|
||||
boolean triggerOnApprovedMergeRequest, String pendingBuildName, boolean cancelPendingBuildsOnUpdate) {
|
||||
public GiteePushTrigger(boolean triggerOnPush, boolean triggerOnMergeRequest, boolean triggerOnAcceptedMergeRequest, boolean triggerOnClosedMergeRequest,
|
||||
TriggerOpenMergeRequest triggerOpenMergeRequestOnPush, boolean triggerOnNoteRequest, String noteRegex,
|
||||
boolean skipWorkInProgressMergeRequest, boolean ciSkip,
|
||||
boolean setBuildDescription, boolean addNoteOnMergeRequest, boolean addCiMessage, boolean addVoteOnMergeRequest,
|
||||
boolean acceptMergeRequestOnSuccess, BranchFilterType branchFilterType,
|
||||
String includeBranchesSpec, String excludeBranchesSpec, String targetBranchRegex,
|
||||
MergeRequestLabelFilterConfig mergeRequestLabelFilterConfig, String secretToken, boolean triggerOnPipelineEvent,
|
||||
boolean triggerOnApprovedMergeRequest, String pendingBuildName, boolean cancelPendingBuildsOnUpdate) {
|
||||
this.triggerOnPush = triggerOnPush;
|
||||
this.triggerOnMergeRequest = triggerOnMergeRequest;
|
||||
this.triggerOnAcceptedMergeRequest = triggerOnAcceptedMergeRequest;
|
||||
|
@ -155,14 +155,14 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
|
|||
}
|
||||
|
||||
@DataBoundConstructor
|
||||
public GitLabPushTrigger() { }
|
||||
public GiteePushTrigger() { }
|
||||
|
||||
@Initializer(after = InitMilestone.JOB_LOADED)
|
||||
public static void migrateJobs() throws IOException {
|
||||
GitLabPushTrigger.DescriptorImpl oldConfig = Trigger.all().get(GitLabPushTrigger.DescriptorImpl.class);
|
||||
GiteePushTrigger.DescriptorImpl oldConfig = Trigger.all().get(GiteePushTrigger.DescriptorImpl.class);
|
||||
if (!oldConfig.jobsMigrated) {
|
||||
GitLabConnectionConfig gitLabConfig = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class);
|
||||
gitLabConfig.getConnections().add(new GitLabConnection(
|
||||
GiteeConnectionConfig giteeConfig = (GiteeConnectionConfig) Jenkins.getInstance().getDescriptor(GiteeConnectionConfig.class);
|
||||
giteeConfig.getConnections().add(new GiteeConnection(
|
||||
oldConfig.gitlabHostUrl,
|
||||
oldConfig.gitlabHostUrl,
|
||||
oldConfig.gitlabApiToken,
|
||||
|
@ -171,33 +171,33 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
|
|||
10,
|
||||
10));
|
||||
|
||||
String defaultConnectionName = gitLabConfig.getConnections().get(0).getName();
|
||||
String defaultConnectionName = giteeConfig.getConnections().get(0).getName();
|
||||
for (AbstractProject<?, ?> project : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
|
||||
GitLabPushTrigger trigger = project.getTrigger(GitLabPushTrigger.class);
|
||||
GiteePushTrigger trigger = project.getTrigger(GiteePushTrigger.class);
|
||||
if (trigger != null) {
|
||||
if (trigger.addCiMessage) {
|
||||
project.getPublishersList().add(new GitLabCommitStatusPublisher("jenkins", false));
|
||||
project.getPublishersList().add(new GiteeCommitStatusPublisher("jenkins", false));
|
||||
}
|
||||
project.addProperty(new GitLabConnectionProperty(defaultConnectionName));
|
||||
project.addProperty(new GiteeConnectionProperty(defaultConnectionName));
|
||||
project.save();
|
||||
}
|
||||
}
|
||||
gitLabConfig.save();
|
||||
giteeConfig.save();
|
||||
oldConfig.jobsMigrated = true;
|
||||
oldConfig.save();
|
||||
}
|
||||
if (!oldConfig.jobsMigrated2) {
|
||||
for (AbstractProject<?, ?> project : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
|
||||
GitLabPushTrigger trigger = project.getTrigger(GitLabPushTrigger.class);
|
||||
GiteePushTrigger trigger = project.getTrigger(GiteePushTrigger.class);
|
||||
if (trigger != null) {
|
||||
if (trigger.addNoteOnMergeRequest) {
|
||||
project.getPublishersList().add(new GitLabMessagePublisher());
|
||||
project.getPublishersList().add(new GiteeMessagePublisher());
|
||||
}
|
||||
if (trigger.addVoteOnMergeRequest) {
|
||||
project.getPublishersList().add(new GitLabVotePublisher());
|
||||
project.getPublishersList().add(new GiteeVotePublisher());
|
||||
}
|
||||
if (trigger.acceptMergeRequestOnSuccess) {
|
||||
project.getPublishersList().add(new GitLabAcceptMergeRequestPublisher());
|
||||
project.getPublishersList().add(new GiteeAcceptMergeRequestPublisher());
|
||||
}
|
||||
project.save();
|
||||
}
|
||||
|
@ -492,13 +492,13 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
|
|||
return super.readResolve();
|
||||
}
|
||||
|
||||
public static GitLabPushTrigger getFromJob(Job<?, ?> job) {
|
||||
GitLabPushTrigger trigger = null;
|
||||
public static GiteePushTrigger getFromJob(Job<?, ?> job) {
|
||||
GiteePushTrigger trigger = null;
|
||||
if (job instanceof ParameterizedJobMixIn.ParameterizedJob) {
|
||||
ParameterizedJobMixIn.ParameterizedJob p = (ParameterizedJobMixIn.ParameterizedJob) job;
|
||||
for (Trigger t : p.getTriggers().values()) {
|
||||
if (t instanceof GitLabPushTrigger) {
|
||||
trigger = (GitLabPushTrigger) t;
|
||||
if (t instanceof GiteePushTrigger) {
|
||||
trigger = (GiteePushTrigger) t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
|
|||
}
|
||||
|
||||
@Extension
|
||||
@Symbol("gitlab")
|
||||
@Symbol("gitee")
|
||||
public static class DescriptorImpl extends TriggerDescriptor {
|
||||
|
||||
private transient final SequentialExecutionQueue queue = new SequentialExecutionQueue(Jenkins.MasterComputer.threadPoolForRemoting);
|
||||
|
@ -543,7 +543,7 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
|
|||
private StringBuilder retrieveProjectUrl(Job<?, ?> project) {
|
||||
return new StringBuilder()
|
||||
.append(Jenkins.getInstance().getRootUrl())
|
||||
.append(GitLabWebHook.WEBHOOK_URL)
|
||||
.append(GiteeWebHook.WEBHOOK_URL)
|
||||
.append(retrieveParentUrl(project))
|
||||
.append('/').append(Util.rawEncode(project.getName()));
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.dabsquared.gitlabjenkins.cause;
|
||||
package com.dabsquared.giteejenkins.cause;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.MergeRequest;
|
||||
import hudson.markup.EscapedMarkupFormatter;
|
||||
import jenkins.model.Jenkins;
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.cause;
|
||||
package com.dabsquared.giteejenkins.cause;
|
||||
|
||||
import hudson.triggers.SCMTrigger;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.connection;
|
||||
package com.dabsquared.giteejenkins.connection;
|
||||
|
||||
import com.cloudbees.plugins.credentials.CredentialsNameProvider;
|
||||
import com.cloudbees.plugins.credentials.NameWith;
|
||||
|
@ -9,14 +9,14 @@ import hudson.util.Secret;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
@NameWith(GitLabApiToken.NameProvider.class)
|
||||
public interface GitLabApiToken extends StandardCredentials {
|
||||
@NameWith(GiteeApiToken.NameProvider.class)
|
||||
public interface GiteeApiToken extends StandardCredentials {
|
||||
|
||||
Secret getApiToken();
|
||||
|
||||
class NameProvider extends CredentialsNameProvider<GitLabApiToken> {
|
||||
class NameProvider extends CredentialsNameProvider<GiteeApiToken> {
|
||||
@Override
|
||||
public String getName(GitLabApiToken c) {
|
||||
public String getName(GiteeApiToken c) {
|
||||
String description = Util.fixEmptyAndTrim(c.getDescription());
|
||||
return Messages.GitLabApiToken_name() + (description != null ? " (" + description + ")" : "");
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.connection;
|
||||
package com.dabsquared.giteejenkins.connection;
|
||||
|
||||
import com.cloudbees.plugins.credentials.CredentialsScope;
|
||||
import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;
|
||||
|
@ -9,12 +9,12 @@ import org.kohsuke.stapler.DataBoundConstructor;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public final class GitLabApiTokenImpl extends BaseStandardCredentials implements GitLabApiToken {
|
||||
public final class GiteeApiTokenImpl extends BaseStandardCredentials implements GiteeApiToken {
|
||||
|
||||
private Secret apiToken;
|
||||
|
||||
@DataBoundConstructor
|
||||
public GitLabApiTokenImpl(CredentialsScope scope, String id, String description, Secret apiToken) {
|
||||
public GiteeApiTokenImpl(CredentialsScope scope, String id, String description, Secret apiToken) {
|
||||
super(scope, id, description);
|
||||
this.apiToken = apiToken;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.connection;
|
||||
package com.dabsquared.giteejenkins.connection;
|
||||
|
||||
|
||||
import com.cloudbees.plugins.credentials.CredentialsMatchers;
|
||||
|
@ -9,9 +9,9 @@ import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
|
|||
import com.cloudbees.plugins.credentials.common.StandardCredentials;
|
||||
import com.cloudbees.plugins.credentials.domains.Domain;
|
||||
import com.cloudbees.plugins.credentials.domains.DomainRequirement;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClientBuilder;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectGitLabClientBuilder;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClientBuilder;
|
||||
import com.dabsquared.giteejenkins.gitee.api.impl.AutodetectGiteeClientBuilder;
|
||||
import hudson.init.InitMilestone;
|
||||
import hudson.init.Initializer;
|
||||
import hudson.model.Item;
|
||||
|
@ -29,30 +29,30 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import static com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials;
|
||||
import static com.dabsquared.gitlabjenkins.gitlab.api.GitLabClientBuilder.getGitLabClientBuilderById;
|
||||
import static com.dabsquared.giteejenkins.gitee.api.GiteeClientBuilder.getGitLabClientBuilderById;
|
||||
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public class GitLabConnection {
|
||||
public class GiteeConnection {
|
||||
private final String name;
|
||||
private final String url;
|
||||
private transient String apiToken;
|
||||
// TODO make final when migration code gets removed
|
||||
private String apiTokenId;
|
||||
private GitLabClientBuilder clientBuilder;
|
||||
private GiteeClientBuilder clientBuilder;
|
||||
private final boolean ignoreCertificateErrors;
|
||||
private final Integer connectionTimeout;
|
||||
private final Integer readTimeout;
|
||||
private transient GitLabClient apiCache;
|
||||
private transient GiteeClient apiCache;
|
||||
|
||||
public GitLabConnection(String name, String url, String apiTokenId, boolean ignoreCertificateErrors, Integer connectionTimeout, Integer readTimeout) {
|
||||
public GiteeConnection(String name, String url, String apiTokenId, boolean ignoreCertificateErrors, Integer connectionTimeout, Integer readTimeout) {
|
||||
this(
|
||||
name,
|
||||
url,
|
||||
apiTokenId,
|
||||
new AutodetectGitLabClientBuilder(),
|
||||
new AutodetectGiteeClientBuilder(),
|
||||
ignoreCertificateErrors,
|
||||
connectionTimeout,
|
||||
readTimeout
|
||||
|
@ -60,7 +60,7 @@ public class GitLabConnection {
|
|||
}
|
||||
|
||||
@DataBoundConstructor
|
||||
public GitLabConnection(String name, String url, String apiTokenId, String clientBuilderId, boolean ignoreCertificateErrors, Integer connectionTimeout, Integer readTimeout) {
|
||||
public GiteeConnection(String name, String url, String apiTokenId, String clientBuilderId, boolean ignoreCertificateErrors, Integer connectionTimeout, Integer readTimeout) {
|
||||
this(
|
||||
name,
|
||||
url,
|
||||
|
@ -73,7 +73,7 @@ public class GitLabConnection {
|
|||
}
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
public GitLabConnection(String name, String url, String apiTokenId, GitLabClientBuilder clientBuilder, boolean ignoreCertificateErrors, Integer connectionTimeout, Integer readTimeout) {
|
||||
public GiteeConnection(String name, String url, String apiTokenId, GiteeClientBuilder clientBuilder, boolean ignoreCertificateErrors, Integer connectionTimeout, Integer readTimeout) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.apiTokenId = apiTokenId;
|
||||
|
@ -111,7 +111,7 @@ public class GitLabConnection {
|
|||
return readTimeout;
|
||||
}
|
||||
|
||||
public GitLabClient getClient() {
|
||||
public GiteeClient getClient() {
|
||||
if (apiCache == null) {
|
||||
apiCache = clientBuilder.buildClient(url, getApiToken(apiTokenId), ignoreCertificateErrors, connectionTimeout, readTimeout);
|
||||
}
|
||||
|
@ -124,8 +124,8 @@ public class GitLabConnection {
|
|||
lookupCredentials(StandardCredentials.class, (Item) null, ACL.SYSTEM, new ArrayList<DomainRequirement>()),
|
||||
CredentialsMatchers.withId(apiTokenId));
|
||||
if (credentials != null) {
|
||||
if (credentials instanceof GitLabApiToken) {
|
||||
return ((GitLabApiToken) credentials).getApiToken().getPlainText();
|
||||
if (credentials instanceof GiteeApiToken) {
|
||||
return ((GiteeApiToken) credentials).getApiToken().getPlainText();
|
||||
}
|
||||
if (credentials instanceof StringCredentials) {
|
||||
return ((StringCredentials) credentials).getSecret().getPlainText();
|
||||
|
@ -135,12 +135,12 @@ public class GitLabConnection {
|
|||
}
|
||||
|
||||
|
||||
protected GitLabConnection readResolve() {
|
||||
protected GiteeConnection readResolve() {
|
||||
if (connectionTimeout == null || readTimeout == null) {
|
||||
return new GitLabConnection(name, url, apiTokenId, new AutodetectGitLabClientBuilder(), ignoreCertificateErrors, 10, 10);
|
||||
return new GiteeConnection(name, url, apiTokenId, new AutodetectGiteeClientBuilder(), ignoreCertificateErrors, 10, 10);
|
||||
}
|
||||
if (clientBuilder == null) {
|
||||
return new GitLabConnection(name, url, apiTokenId, new AutodetectGitLabClientBuilder(), ignoreCertificateErrors, connectionTimeout, readTimeout);
|
||||
return new GiteeConnection(name, url, apiTokenId, new AutodetectGiteeClientBuilder(), ignoreCertificateErrors, connectionTimeout, readTimeout);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -148,15 +148,15 @@ public class GitLabConnection {
|
|||
|
||||
@Initializer(after = InitMilestone.PLUGINS_STARTED)
|
||||
public static void migrate() throws IOException {
|
||||
GitLabConnectionConfig descriptor = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class);
|
||||
for (GitLabConnection connection : descriptor.getConnections()) {
|
||||
GiteeConnectionConfig descriptor = (GiteeConnectionConfig) Jenkins.getInstance().getDescriptor(GiteeConnectionConfig.class);
|
||||
for (GiteeConnection connection : descriptor.getConnections()) {
|
||||
if (connection.apiTokenId == null && connection.apiToken != null) {
|
||||
for (CredentialsStore credentialsStore : CredentialsProvider.lookupStores(Jenkins.getInstance())) {
|
||||
if (credentialsStore instanceof SystemCredentialsProvider.StoreImpl) {
|
||||
List<Domain> domains = credentialsStore.getDomains();
|
||||
connection.apiTokenId = UUID.randomUUID().toString();
|
||||
credentialsStore.addCredentials(domains.get(0),
|
||||
new GitLabApiTokenImpl(CredentialsScope.SYSTEM, connection.apiTokenId, "GitLab API Token", Secret.fromString(connection.apiToken)));
|
||||
new GiteeApiTokenImpl(CredentialsScope.SYSTEM, connection.apiTokenId, "GitLab API Token", Secret.fromString(connection.apiToken)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.connection;
|
||||
package com.dabsquared.giteejenkins.connection;
|
||||
|
||||
|
||||
import com.cloudbees.plugins.credentials.Credentials;
|
||||
|
@ -7,8 +7,8 @@ import com.cloudbees.plugins.credentials.common.AbstractIdCredentialsListBoxMode
|
|||
import com.cloudbees.plugins.credentials.common.StandardCredentials;
|
||||
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
|
||||
import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClientBuilder;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClientBuilder;
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import hudson.Extension;
|
||||
import hudson.model.Item;
|
||||
|
@ -30,27 +30,27 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.gitlab.api.GitLabClientBuilder.getAllGitLabClientBuilders;
|
||||
import static com.dabsquared.giteejenkins.gitee.api.GiteeClientBuilder.getAllGitLabClientBuilders;
|
||||
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
@Extension
|
||||
public class GitLabConnectionConfig extends GlobalConfiguration {
|
||||
public class GiteeConnectionConfig extends GlobalConfiguration {
|
||||
|
||||
private Boolean useAuthenticatedEndpoint = true;
|
||||
private List<GitLabConnection> connections = new ArrayList<>();
|
||||
private transient Map<String, GitLabConnection> connectionMap = new HashMap<>();
|
||||
private List<GiteeConnection> connections = new ArrayList<>();
|
||||
private transient Map<String, GiteeConnection> connectionMap = new HashMap<>();
|
||||
|
||||
public GitLabConnectionConfig() {
|
||||
public GiteeConnectionConfig() {
|
||||
load();
|
||||
refreshConnectionMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
|
||||
connections = req.bindJSONToList(GitLabConnection.class, json.get("connections"));
|
||||
connections = req.bindJSONToList(GiteeConnection.class, json.get("connections"));
|
||||
useAuthenticatedEndpoint = json.getBoolean("useAuthenticatedEndpoint");
|
||||
refreshConnectionMap();
|
||||
save();
|
||||
|
@ -65,24 +65,24 @@ public class GitLabConnectionConfig extends GlobalConfiguration {
|
|||
this.useAuthenticatedEndpoint = useAuthenticatedEndpoint;
|
||||
}
|
||||
|
||||
public List<GitLabConnection> getConnections() {
|
||||
public List<GiteeConnection> getConnections() {
|
||||
return connections;
|
||||
}
|
||||
|
||||
public void addConnection(GitLabConnection connection) {
|
||||
public void addConnection(GiteeConnection connection) {
|
||||
connections.add(connection);
|
||||
connectionMap.put(connection.getName(), connection);
|
||||
}
|
||||
|
||||
public void setConnections(List<GitLabConnection> newConnections) {
|
||||
public void setConnections(List<GiteeConnection> newConnections) {
|
||||
connections = new ArrayList<>();
|
||||
connectionMap = new HashMap<>();
|
||||
for (GitLabConnection connection: newConnections){
|
||||
for (GiteeConnection connection: newConnections){
|
||||
addConnection(connection);
|
||||
}
|
||||
}
|
||||
|
||||
public GitLabClient getClient(String connectionName) {
|
||||
public GiteeClient getClient(String connectionName) {
|
||||
if (!connectionMap.containsKey(connectionName)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class GitLabConnectionConfig extends GlobalConfiguration {
|
|||
@QueryParameter int connectionTimeout,
|
||||
@QueryParameter int readTimeout) {
|
||||
try {
|
||||
new GitLabConnection("", url, apiTokenId, clientBuilderId, ignoreCertificateErrors, connectionTimeout, readTimeout).getClient().getCurrentUser();
|
||||
new GiteeConnection("", url, apiTokenId, clientBuilderId, ignoreCertificateErrors, connectionTimeout, readTimeout).getClient().getCurrentUser();
|
||||
return FormValidation.ok(Messages.connection_success());
|
||||
} catch (WebApplicationException e) {
|
||||
return FormValidation.error(Messages.connection_error(e.getMessage()));
|
||||
|
@ -155,7 +155,7 @@ public class GitLabConnectionConfig extends GlobalConfiguration {
|
|||
Jenkins.getActiveInstance(),
|
||||
StandardCredentials.class,
|
||||
URIRequirementBuilder.fromUri(url).build(),
|
||||
new GitLabCredentialMatcher());
|
||||
new GiteeCredentialMatcher());
|
||||
if (name != null && connectionMap.containsKey(name)) {
|
||||
String apiTokenId = connectionMap.get(name).getApiTokenId();
|
||||
options.includeCurrentValue(apiTokenId);
|
||||
|
@ -172,7 +172,7 @@ public class GitLabConnectionConfig extends GlobalConfiguration {
|
|||
|
||||
public ListBoxModel doFillClientBuilderIdItems() {
|
||||
ListBoxModel model = new ListBoxModel();
|
||||
for (GitLabClientBuilder builder : getAllGitLabClientBuilders()) {
|
||||
for (GiteeClientBuilder builder : getAllGitLabClientBuilders()) {
|
||||
model.add(builder.id());
|
||||
}
|
||||
|
||||
|
@ -181,23 +181,23 @@ public class GitLabConnectionConfig extends GlobalConfiguration {
|
|||
|
||||
private void refreshConnectionMap() {
|
||||
connectionMap.clear();
|
||||
for (GitLabConnection connection : connections) {
|
||||
for (GiteeConnection connection : connections) {
|
||||
connectionMap.put(connection.getName(), connection);
|
||||
}
|
||||
}
|
||||
|
||||
private static class GitLabCredentialMatcher implements CredentialsMatcher {
|
||||
private static class GiteeCredentialMatcher implements CredentialsMatcher {
|
||||
@Override
|
||||
public boolean matches(@NonNull Credentials credentials) {
|
||||
try {
|
||||
return credentials instanceof GitLabApiToken || credentials instanceof StringCredentials;
|
||||
return credentials instanceof GiteeApiToken || credentials instanceof StringCredentials;
|
||||
} catch (Throwable e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//For backwards compatibility. ReadResolve is called on startup
|
||||
protected GitLabConnectionConfig readResolve() {
|
||||
protected GiteeConnectionConfig readResolve() {
|
||||
if (useAuthenticatedEndpoint == null) {
|
||||
setUseAuthenticatedEndpoint(false);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.dabsquared.gitlabjenkins.connection;
|
||||
package com.dabsquared.giteejenkins.connection;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import hudson.Extension;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.JobProperty;
|
||||
|
@ -18,12 +18,12 @@ import org.kohsuke.stapler.StaplerRequest;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public class GitLabConnectionProperty extends JobProperty<Job<?, ?>> {
|
||||
public class GiteeConnectionProperty extends JobProperty<Job<?, ?>> {
|
||||
|
||||
private String gitLabConnection;
|
||||
|
||||
@DataBoundConstructor
|
||||
public GitLabConnectionProperty(String gitLabConnection) {
|
||||
public GiteeConnectionProperty(String gitLabConnection) {
|
||||
this.gitLabConnection = gitLabConnection;
|
||||
}
|
||||
|
||||
|
@ -31,16 +31,16 @@ public class GitLabConnectionProperty extends JobProperty<Job<?, ?>> {
|
|||
return gitLabConnection;
|
||||
}
|
||||
|
||||
public GitLabClient getClient() {
|
||||
public GiteeClient getClient() {
|
||||
if (StringUtils.isNotEmpty(gitLabConnection)) {
|
||||
GitLabConnectionConfig connectionConfig = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class);
|
||||
GiteeConnectionConfig connectionConfig = (GiteeConnectionConfig) Jenkins.getInstance().getDescriptor(GiteeConnectionConfig.class);
|
||||
return connectionConfig != null ? connectionConfig.getClient(gitLabConnection) : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static GitLabClient getClient(Run<?, ?> build) {
|
||||
final GitLabConnectionProperty connectionProperty = build.getParent().getProperty(GitLabConnectionProperty.class);
|
||||
public static GiteeClient getClient(Run<?, ?> build) {
|
||||
final GiteeConnectionProperty connectionProperty = build.getParent().getProperty(GiteeConnectionProperty.class);
|
||||
if (connectionProperty != null) {
|
||||
return connectionProperty.getClient();
|
||||
}
|
||||
|
@ -63,13 +63,13 @@ public class GitLabConnectionProperty extends JobProperty<Job<?, ?>> {
|
|||
|
||||
@Override
|
||||
public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException {
|
||||
return req.bindJSON(GitLabConnectionProperty.class, formData);
|
||||
return req.bindJSON(GiteeConnectionProperty.class, formData);
|
||||
}
|
||||
|
||||
public ListBoxModel doFillGitLabConnectionItems() {
|
||||
ListBoxModel options = new ListBoxModel();
|
||||
GitLabConnectionConfig descriptor = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class);
|
||||
for (GitLabConnection connection : descriptor.getConnections()) {
|
||||
GiteeConnectionConfig descriptor = (GiteeConnectionConfig) Jenkins.getInstance().getDescriptor(GiteeConnectionConfig.class);
|
||||
for (GiteeConnection connection : descriptor.getConnections()) {
|
||||
options.add(connection.getName(), connection.getName());
|
||||
}
|
||||
return options;
|
|
@ -1,6 +1,6 @@
|
|||
package com.dabsquared.gitlabjenkins.environment;
|
||||
package com.dabsquared.giteejenkins.environment;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.giteejenkins.cause.GiteeWebHookCause;
|
||||
import hudson.EnvVars;
|
||||
import hudson.Extension;
|
||||
import hudson.matrix.MatrixRun;
|
||||
|
@ -16,7 +16,7 @@ import java.io.IOException;
|
|||
* @author Robin Müller
|
||||
*/
|
||||
@Extension
|
||||
public class GitLabEnvironmentContributor extends EnvironmentContributor {
|
||||
public class GiteeEnvironmentContributor extends EnvironmentContributor {
|
||||
@Override
|
||||
public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException {
|
||||
GiteeWebHookCause cause = null;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab;
|
||||
package com.dabsquared.giteejenkins.gitee;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@ -1,11 +1,11 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api;
|
||||
package com.dabsquared.giteejenkins.gitee.api;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.*;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.*;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GitLabClient {
|
||||
public interface GiteeClient {
|
||||
String getHostUrl();
|
||||
|
||||
Project createProject(String projectName);
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api;
|
||||
package com.dabsquared.giteejenkins.gitee.api;
|
||||
|
||||
|
||||
import hudson.ExtensionPoint;
|
||||
|
@ -15,9 +15,9 @@ import java.util.NoSuchElementException;
|
|||
import static java.util.Collections.sort;
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
public abstract class GitLabClientBuilder implements Comparable<GitLabClientBuilder>, ExtensionPoint, Serializable {
|
||||
public static GitLabClientBuilder getGitLabClientBuilderById(String id) {
|
||||
for (GitLabClientBuilder provider : getAllGitLabClientBuilders()) {
|
||||
public abstract class GiteeClientBuilder implements Comparable<GiteeClientBuilder>, ExtensionPoint, Serializable {
|
||||
public static GiteeClientBuilder getGitLabClientBuilderById(String id) {
|
||||
for (GiteeClientBuilder provider : getAllGitLabClientBuilders()) {
|
||||
if (provider.id().equals(id)) {
|
||||
return provider;
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ public abstract class GitLabClientBuilder implements Comparable<GitLabClientBuil
|
|||
throw new NoSuchElementException("unknown client-builder-id: " + id);
|
||||
}
|
||||
|
||||
public static List<GitLabClientBuilder> getAllGitLabClientBuilders() {
|
||||
List<GitLabClientBuilder> builders = new ArrayList<>(Jenkins.getInstance().getExtensionList(GitLabClientBuilder.class));
|
||||
public static List<GiteeClientBuilder> getAllGitLabClientBuilders() {
|
||||
List<GiteeClientBuilder> builders = new ArrayList<>(Jenkins.getInstance().getExtensionList(GiteeClientBuilder.class));
|
||||
sort(builders);
|
||||
return builders;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public abstract class GitLabClientBuilder implements Comparable<GitLabClientBuil
|
|||
private final String id;
|
||||
private final int ordinal;
|
||||
|
||||
protected GitLabClientBuilder(String id, int ordinal) {
|
||||
protected GiteeClientBuilder(String id, int ordinal) {
|
||||
this.id = id;
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
@ -46,10 +46,10 @@ public abstract class GitLabClientBuilder implements Comparable<GitLabClientBuil
|
|||
}
|
||||
|
||||
@Nonnull
|
||||
public abstract GitLabClient buildClient(String url, String token, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout);
|
||||
public abstract GiteeClient buildClient(String url, String token, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout);
|
||||
|
||||
@Override
|
||||
public final int compareTo(@Nonnull GitLabClientBuilder other) {
|
||||
public final int compareTo(@Nonnull GiteeClientBuilder other) {
|
||||
int o = ordinal - other.ordinal;
|
||||
return o != 0 ? o : id().compareTo(other.id());
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.dabsquared.giteejenkins.gitee.api.impl;
|
||||
|
||||
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClientBuilder;
|
||||
import hudson.Extension;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@Extension
|
||||
@Restricted(NoExternalUse.class)
|
||||
public final class AutodetectGiteeClientBuilder extends GiteeClientBuilder {
|
||||
public AutodetectGiteeClientBuilder() {
|
||||
super("autodetect", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public GiteeClient buildClient(String url, String token, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout) {
|
||||
Collection<GiteeClientBuilder> candidates = new ArrayList<>(getAllGitLabClientBuilders());
|
||||
candidates.remove(this);
|
||||
return new AutodetectingGiteeClient(candidates, url, token, ignoreCertificateErrors, connectionTimeout, readTimeout);
|
||||
}
|
||||
}
|
|
@ -1,27 +1,27 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.impl;
|
||||
package com.dabsquared.giteejenkins.gitee.api.impl;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClientBuilder;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.*;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClientBuilder;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.*;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
|
||||
import javax.ws.rs.NotFoundException;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
||||
final class AutodetectingGitLabClient implements GitLabClient {
|
||||
private final Iterable<GitLabClientBuilder> builders;
|
||||
final class AutodetectingGiteeClient implements GiteeClient {
|
||||
private final Iterable<GiteeClientBuilder> builders;
|
||||
private final String url;
|
||||
private final String token;
|
||||
private final boolean ignoreCertificateErrors;
|
||||
private final int connectionTimeout;
|
||||
private final int readTimeout;
|
||||
private GitLabClient delegate;
|
||||
private GiteeClient delegate;
|
||||
|
||||
|
||||
AutodetectingGitLabClient(Iterable<GitLabClientBuilder> builders, String url, String token, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout) {
|
||||
AutodetectingGiteeClient(Iterable<GiteeClientBuilder> builders, String url, String token, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout) {
|
||||
this.builders = builders;
|
||||
this.url = url;
|
||||
this.token = token;
|
||||
|
@ -38,9 +38,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public Project createProject(final String projectName) {
|
||||
return execute(
|
||||
new GitLabOperation<Project>() {
|
||||
new GiteeOperation<Project>() {
|
||||
@Override
|
||||
Project execute(GitLabClient client) {
|
||||
Project execute(GiteeClient client) {
|
||||
return client.createProject(projectName);
|
||||
}
|
||||
});
|
||||
|
@ -49,9 +49,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public MergeRequest createMergeRequest(final Integer projectId, final String sourceBranch, final String targetBranch, final String title) {
|
||||
return execute(
|
||||
new GitLabOperation<MergeRequest>() {
|
||||
new GiteeOperation<MergeRequest>() {
|
||||
@Override
|
||||
MergeRequest execute(GitLabClient client) {
|
||||
MergeRequest execute(GiteeClient client) {
|
||||
return client.createMergeRequest(projectId, sourceBranch, targetBranch, title);
|
||||
}
|
||||
});
|
||||
|
@ -60,9 +60,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public Project getProject(final String projectName) {
|
||||
return execute(
|
||||
new GitLabOperation<Project>() {
|
||||
new GiteeOperation<Project>() {
|
||||
@Override
|
||||
Project execute(GitLabClient client) {
|
||||
Project execute(GiteeClient client) {
|
||||
return client.getProject(projectName);
|
||||
}
|
||||
});
|
||||
|
@ -71,9 +71,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public Project updateProject(final String projectId, final String name, final String path) {
|
||||
return execute(
|
||||
new GitLabOperation<Project>() {
|
||||
new GiteeOperation<Project>() {
|
||||
@Override
|
||||
Project execute(GitLabClient client) {
|
||||
Project execute(GiteeClient client) {
|
||||
return client.updateProject(projectId, name, path);
|
||||
}
|
||||
});
|
||||
|
@ -82,9 +82,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public void deleteProject(final String projectId) {
|
||||
execute(
|
||||
new GitLabOperation<Void>() {
|
||||
new GiteeOperation<Void>() {
|
||||
@Override
|
||||
Void execute(GitLabClient client) {
|
||||
Void execute(GiteeClient client) {
|
||||
client.deleteProject(projectId);
|
||||
return null;
|
||||
}
|
||||
|
@ -94,9 +94,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public void addProjectHook(final String projectId, final String url, final Boolean pushEvents, final Boolean mergeRequestEvents, final Boolean noteEvents) {
|
||||
execute(
|
||||
new GitLabOperation<Void>() {
|
||||
new GiteeOperation<Void>() {
|
||||
@Override
|
||||
Void execute(GitLabClient client) {
|
||||
Void execute(GiteeClient client) {
|
||||
client.addProjectHook(projectId, url, pushEvents, mergeRequestEvents, noteEvents);
|
||||
return null;
|
||||
}
|
||||
|
@ -106,9 +106,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public void changeBuildStatus(final String projectId, final String sha, final BuildState state, final String ref, final String context, final String targetUrl, final String description) {
|
||||
execute(
|
||||
new GitLabOperation<Void>() {
|
||||
new GiteeOperation<Void>() {
|
||||
@Override
|
||||
Void execute(GitLabClient client) {
|
||||
Void execute(GiteeClient client) {
|
||||
client.changeBuildStatus(projectId, sha, state, ref, context, targetUrl, description);
|
||||
return null;
|
||||
}
|
||||
|
@ -118,9 +118,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public void changeBuildStatus(final Integer projectId, final String sha, final BuildState state, final String ref, final String context, final String targetUrl, final String description) {
|
||||
execute(
|
||||
new GitLabOperation<Void>() {
|
||||
new GiteeOperation<Void>() {
|
||||
@Override
|
||||
Void execute(GitLabClient client) {
|
||||
Void execute(GiteeClient client) {
|
||||
client.changeBuildStatus(projectId, sha, state, ref, context, targetUrl, description);
|
||||
return null;
|
||||
}
|
||||
|
@ -130,9 +130,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public void getCommit(final String projectId, final String sha) {
|
||||
execute(
|
||||
new GitLabOperation<Void>() {
|
||||
new GiteeOperation<Void>() {
|
||||
@Override
|
||||
Void execute(GitLabClient client) {
|
||||
Void execute(GiteeClient client) {
|
||||
client.getCommit(projectId, sha);
|
||||
return null;
|
||||
}
|
||||
|
@ -142,9 +142,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public void acceptMergeRequest(final MergeRequest mr, final String mergeCommitMessage, final boolean shouldRemoveSourceBranch) {
|
||||
execute(
|
||||
new GitLabOperation<Void>() {
|
||||
new GiteeOperation<Void>() {
|
||||
@Override
|
||||
Void execute(GitLabClient client) {
|
||||
Void execute(GiteeClient client) {
|
||||
client.acceptMergeRequest(mr, mergeCommitMessage, shouldRemoveSourceBranch);
|
||||
return null;
|
||||
}
|
||||
|
@ -155,9 +155,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public void createMergeRequestNote(final MergeRequest mr, final String body) {
|
||||
execute(
|
||||
new GitLabOperation<Void>() {
|
||||
new GiteeOperation<Void>() {
|
||||
@Override
|
||||
Void execute(GitLabClient client) {
|
||||
Void execute(GiteeClient client) {
|
||||
client.createMergeRequestNote(mr, body);
|
||||
return null;
|
||||
}
|
||||
|
@ -168,9 +168,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public List<MergeRequest> getMergeRequests(final String projectId, final State state, final int page, final int perPage) {
|
||||
return execute(
|
||||
new GitLabOperation<List<MergeRequest>>() {
|
||||
new GiteeOperation<List<MergeRequest>>() {
|
||||
@Override
|
||||
List<MergeRequest> execute(GitLabClient client) {
|
||||
List<MergeRequest> execute(GiteeClient client) {
|
||||
return client.getMergeRequests(projectId, state, page, perPage);
|
||||
}
|
||||
});
|
||||
|
@ -179,9 +179,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public List<Branch> getBranches(final String projectId) {
|
||||
return execute(
|
||||
new GitLabOperation<List<Branch>>() {
|
||||
new GiteeOperation<List<Branch>>() {
|
||||
@Override
|
||||
List<Branch> execute(GitLabClient client) {
|
||||
List<Branch> execute(GiteeClient client) {
|
||||
return client.getBranches(projectId);
|
||||
}
|
||||
});
|
||||
|
@ -190,9 +190,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public Branch getBranch(final String projectId, final String branch) {
|
||||
return execute(
|
||||
new GitLabOperation<Branch>() {
|
||||
new GiteeOperation<Branch>() {
|
||||
@Override
|
||||
Branch execute(GitLabClient client) {
|
||||
Branch execute(GiteeClient client) {
|
||||
return client.getBranch(projectId, branch);
|
||||
}
|
||||
});
|
||||
|
@ -201,9 +201,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public User getCurrentUser() {
|
||||
return execute(
|
||||
new GitLabOperation<User>() {
|
||||
new GiteeOperation<User>() {
|
||||
@Override
|
||||
User execute(GitLabClient client) {
|
||||
User execute(GiteeClient client) {
|
||||
return client.getCurrentUser();
|
||||
}
|
||||
});
|
||||
|
@ -212,9 +212,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public User addUser(final String email, final String username, final String name, final String password) {
|
||||
return execute(
|
||||
new GitLabOperation<User>() {
|
||||
new GiteeOperation<User>() {
|
||||
@Override
|
||||
User execute(GitLabClient client) {
|
||||
User execute(GiteeClient client) {
|
||||
return client.addUser(email, username, name, password);
|
||||
}
|
||||
});
|
||||
|
@ -223,9 +223,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public User updateUser(final String userId, final String email, final String username, final String name, final String password) {
|
||||
return execute(
|
||||
new GitLabOperation<User>() {
|
||||
new GiteeOperation<User>() {
|
||||
@Override
|
||||
User execute(GitLabClient client) {
|
||||
User execute(GiteeClient client) {
|
||||
return client.updateUser(userId, email, username, name, password);
|
||||
}
|
||||
});
|
||||
|
@ -234,9 +234,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public List<Label> getLabels(final String projectId) {
|
||||
return execute(
|
||||
new GitLabOperation<List<Label>>() {
|
||||
new GiteeOperation<List<Label>>() {
|
||||
@Override
|
||||
List<Label> execute(GitLabClient client) {
|
||||
List<Label> execute(GiteeClient client) {
|
||||
return client.getLabels(projectId);
|
||||
}
|
||||
});
|
||||
|
@ -245,16 +245,16 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
@Override
|
||||
public List<Pipeline> getPipelines(final String projectName) {
|
||||
return execute(
|
||||
new GitLabOperation<List<Pipeline>>() {
|
||||
new GiteeOperation<List<Pipeline>>() {
|
||||
@Override
|
||||
List<Pipeline> execute(GitLabClient client) {
|
||||
List<Pipeline> execute(GiteeClient client) {
|
||||
return client.getPipelines(projectName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private GitLabClient delegate(boolean reset) {
|
||||
private GiteeClient delegate(boolean reset) {
|
||||
if (reset || delegate == null) {
|
||||
delegate = autodetectOrDie();
|
||||
}
|
||||
|
@ -262,8 +262,8 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
return delegate;
|
||||
}
|
||||
|
||||
private GitLabClient autodetectOrDie() {
|
||||
GitLabClient client = autodetect();
|
||||
private GiteeClient autodetectOrDie() {
|
||||
GiteeClient client = autodetect();
|
||||
if (client != null) {
|
||||
return client;
|
||||
}
|
||||
|
@ -271,9 +271,9 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
throw new NoSuchElementException("no client-builder found that supports server at " + url);
|
||||
}
|
||||
|
||||
private GitLabClient autodetect() {
|
||||
for (GitLabClientBuilder candidate : builders) {
|
||||
GitLabClient client = candidate.buildClient(url, token, ignoreCertificateErrors, connectionTimeout, readTimeout);
|
||||
private GiteeClient autodetect() {
|
||||
for (GiteeClientBuilder candidate : builders) {
|
||||
GiteeClient client = candidate.buildClient(url, token, ignoreCertificateErrors, connectionTimeout, readTimeout);
|
||||
try {
|
||||
client.getCurrentUser();
|
||||
return client;
|
||||
|
@ -285,12 +285,12 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
return null;
|
||||
}
|
||||
|
||||
private <R> R execute(GitLabOperation<R> operation) {
|
||||
private <R> R execute(GiteeOperation<R> operation) {
|
||||
return operation.execute(false);
|
||||
}
|
||||
|
||||
|
||||
private abstract class GitLabOperation<R> {
|
||||
private abstract class GiteeOperation<R> {
|
||||
private R execute(boolean reset) {
|
||||
try {
|
||||
return execute(delegate(reset));
|
||||
|
@ -304,6 +304,6 @@ final class AutodetectingGitLabClient implements GitLabClient {
|
|||
}
|
||||
|
||||
|
||||
abstract R execute(GitLabClient client);
|
||||
abstract R execute(GiteeClient client);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.impl;
|
||||
package com.dabsquared.giteejenkins.gitee.api.impl;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.*;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.*;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
interface GitLabApiProxy {
|
||||
interface GiteeApiProxy {
|
||||
Project createProject(String projectName);
|
||||
|
||||
MergeRequest createMergeRequest(Integer projectId, String sourceBranch, String targetBranch, String title);
|
|
@ -1,20 +1,20 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.impl;
|
||||
package com.dabsquared.giteejenkins.gitee.api.impl;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.*;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.*;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
final class ResteasyGitLabClient implements GitLabClient {
|
||||
final class ResteasyGiteeClient implements GiteeClient {
|
||||
private final String hostUrl;
|
||||
private final GitLabApiProxy api;
|
||||
private final GiteeApiProxy api;
|
||||
private final Function<MergeRequest, Integer> mergeRequestIdProvider;
|
||||
|
||||
ResteasyGitLabClient(String hostUrl, GitLabApiProxy api, Function<MergeRequest, Integer> mergeRequestIdProvider) {
|
||||
ResteasyGiteeClient(String hostUrl, GiteeApiProxy api, Function<MergeRequest, Integer> mergeRequestIdProvider) {
|
||||
this.hostUrl = hostUrl;
|
||||
this.api = api;
|
||||
this.mergeRequestIdProvider = mergeRequestIdProvider;
|
|
@ -1,12 +1,12 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.impl;
|
||||
package com.dabsquared.giteejenkins.gitee.api.impl;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.JacksonConfig;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClientBuilder;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
|
||||
import com.dabsquared.gitlabjenkins.util.JsonUtil;
|
||||
import com.dabsquared.gitlabjenkins.util.LoggerUtil;
|
||||
import com.dabsquared.giteejenkins.gitee.JacksonConfig;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClientBuilder;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.MergeRequest;
|
||||
import com.dabsquared.giteejenkins.util.JsonUtil;
|
||||
import com.dabsquared.giteejenkins.util.LoggerUtil;
|
||||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
|
@ -57,8 +57,8 @@ import static java.net.Proxy.Type.HTTP;
|
|||
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
public class ResteasyGitLabClientBuilder extends GitLabClientBuilder {
|
||||
private static final Logger LOGGER = Logger.getLogger(ResteasyGitLabClientBuilder.class.getName());
|
||||
public class ResteasyGiteeClientBuilder extends GiteeClientBuilder {
|
||||
private static final Logger LOGGER = Logger.getLogger(ResteasyGiteeClientBuilder.class.getName());
|
||||
private static final String PRIVATE_TOKEN = "PRIVATE-TOKEN";
|
||||
|
||||
@Initializer(before = InitMilestone.PLUGINS_STARTED)
|
||||
|
@ -66,10 +66,10 @@ public class ResteasyGitLabClientBuilder extends GitLabClientBuilder {
|
|||
RuntimeDelegate.setInstance(new ResteasyProviderFactory());
|
||||
}
|
||||
|
||||
private final Class<? extends GitLabApiProxy> apiProxyClass;
|
||||
private final Class<? extends GiteeApiProxy> apiProxyClass;
|
||||
private final Function<MergeRequest, Integer> mergeRequestIdProvider;
|
||||
|
||||
ResteasyGitLabClientBuilder(String id, int ordinal, Class<? extends GitLabApiProxy> apiProxyClass, Function<MergeRequest, Integer> mergeRequestIdProvider) {
|
||||
ResteasyGiteeClientBuilder(String id, int ordinal, Class<? extends GiteeApiProxy> apiProxyClass, Function<MergeRequest, Integer> mergeRequestIdProvider) {
|
||||
super(id, ordinal);
|
||||
this.apiProxyClass = apiProxyClass;
|
||||
this.mergeRequestIdProvider = mergeRequestIdProvider;
|
||||
|
@ -77,7 +77,7 @@ public class ResteasyGitLabClientBuilder extends GitLabClientBuilder {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final GitLabClient buildClient(String url, String apiToken, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout) {
|
||||
public final GiteeClient buildClient(String url, String apiToken, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout) {
|
||||
return buildClient(
|
||||
url,
|
||||
apiToken,
|
||||
|
@ -88,7 +88,7 @@ public class ResteasyGitLabClientBuilder extends GitLabClientBuilder {
|
|||
);
|
||||
}
|
||||
|
||||
private GitLabClient buildClient(String url, String apiToken, ProxyConfiguration httpProxyConfig, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout) {
|
||||
private GiteeClient buildClient(String url, String apiToken, ProxyConfiguration httpProxyConfig, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout) {
|
||||
ResteasyClientBuilder builder = new ResteasyClientBuilder();
|
||||
|
||||
if (ignoreCertificateErrors) {
|
||||
|
@ -108,7 +108,7 @@ public class ResteasyGitLabClientBuilder extends GitLabClientBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
GitLabApiProxy apiProxy = builder
|
||||
GiteeApiProxy apiProxy = builder
|
||||
.connectionPoolSize(60)
|
||||
.maxPooledPerRoute(30)
|
||||
.establishConnectionTimeout(connectionTimeout, TimeUnit.SECONDS)
|
||||
|
@ -124,7 +124,7 @@ public class ResteasyGitLabClientBuilder extends GitLabClientBuilder {
|
|||
.classloader(apiProxyClass.getClassLoader())
|
||||
.build();
|
||||
|
||||
return new ResteasyGitLabClient(url, apiProxy, mergeRequestIdProvider);
|
||||
return new ResteasyGiteeClient(url, apiProxy, mergeRequestIdProvider);
|
||||
}
|
||||
|
||||
private String getHost(String url) {
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.impl;
|
||||
package com.dabsquared.giteejenkins.gitee.api.impl;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.*;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.*;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
|
@ -18,14 +18,14 @@ import javax.ws.rs.QueryParam;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.gitlab.api.impl.V3GitLabApiProxy.ID;
|
||||
import static com.dabsquared.giteejenkins.gitee.api.impl.V3GiteeApiProxy.ID;
|
||||
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
@Path("/api/" + ID)
|
||||
interface V3GitLabApiProxy extends GitLabApiProxy {
|
||||
interface V3GiteeApiProxy extends GiteeApiProxy {
|
||||
String ID = "v3";
|
||||
|
||||
@POST
|
|
@ -1,7 +1,7 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.impl;
|
||||
package com.dabsquared.giteejenkins.gitee.api.impl;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.MergeRequest;
|
||||
import com.google.common.base.Function;
|
||||
import hudson.Extension;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
|
@ -10,7 +10,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse;
|
|||
|
||||
@Extension
|
||||
@Restricted(NoExternalUse.class)
|
||||
public final class V3GitLabClientBuilder extends ResteasyGitLabClientBuilder {
|
||||
public final class V3GiteeClientBuilder extends ResteasyGiteeClientBuilder {
|
||||
private static final int ORDINAL = 2;
|
||||
private static final Function<MergeRequest, Integer> MERGE_REQUEST_ID_PROVIDER = new Function<MergeRequest, Integer>() {
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ public final class V3GitLabClientBuilder extends ResteasyGitLabClientBuilder {
|
|||
}
|
||||
};
|
||||
|
||||
public V3GitLabClientBuilder() {
|
||||
super(V3GitLabApiProxy.ID, ORDINAL, V3GitLabApiProxy.class, MERGE_REQUEST_ID_PROVIDER);
|
||||
public V3GiteeClientBuilder() {
|
||||
super(V3GiteeApiProxy.ID, ORDINAL, V3GiteeApiProxy.class, MERGE_REQUEST_ID_PROVIDER);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.impl;
|
||||
package com.dabsquared.giteejenkins.gitee.api.impl;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.*;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.*;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
|
@ -18,14 +18,14 @@ import javax.ws.rs.QueryParam;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.gitlab.api.impl.V4GitLabApiProxy.ID;
|
||||
import static com.dabsquared.giteejenkins.gitee.api.impl.V4GiteeApiProxy.ID;
|
||||
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
@Path("/api/" + ID)
|
||||
interface V4GitLabApiProxy extends GitLabApiProxy {
|
||||
interface V4GiteeApiProxy extends GiteeApiProxy {
|
||||
String ID = "v4";
|
||||
|
||||
@POST
|
|
@ -1,7 +1,7 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.impl;
|
||||
package com.dabsquared.giteejenkins.gitee.api.impl;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.MergeRequest;
|
||||
import com.google.common.base.Function;
|
||||
import hudson.Extension;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
|
@ -10,7 +10,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse;
|
|||
|
||||
@Extension
|
||||
@Restricted(NoExternalUse.class)
|
||||
public final class V4GitLabClientBuilder extends ResteasyGitLabClientBuilder {
|
||||
public final class V4GiteeClientBuilder extends ResteasyGiteeClientBuilder {
|
||||
private static final int ORDINAL = 1;
|
||||
private static final Function<MergeRequest, Integer> MERGE_REQUEST_ID_PROVIDER = new Function<MergeRequest, Integer>() {
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ public final class V4GitLabClientBuilder extends ResteasyGitLabClientBuilder {
|
|||
}
|
||||
};
|
||||
|
||||
public V4GitLabClientBuilder() {
|
||||
super(V4GitLabApiProxy.ID, ORDINAL, V4GitLabApiProxy.class, MERGE_REQUEST_ID_PROVIDER);
|
||||
public V4GiteeClientBuilder() {
|
||||
super(V4GiteeApiProxy.ID, ORDINAL, V4GiteeApiProxy.class, MERGE_REQUEST_ID_PROVIDER);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,6 +1,6 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.api.model;
|
||||
package com.dabsquared.giteejenkins.gitee.api.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
|
@ -6,7 +6,6 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
|
|||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.gitlab.hook.model;
|
||||
package com.dabsquared.giteejenkins.gitee.hook.model;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
@ -1,7 +1,7 @@
|
|||
package com.dabsquared.gitlabjenkins.listener;
|
||||
package com.dabsquared.giteejenkins.listener;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.GitLabPushTrigger;
|
||||
import com.dabsquared.gitlabjenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.giteejenkins.GiteePushTrigger;
|
||||
import com.dabsquared.giteejenkins.cause.GiteeWebHookCause;
|
||||
import hudson.Extension;
|
||||
import hudson.model.Cause;
|
||||
import hudson.model.Run;
|
||||
|
@ -12,16 +12,16 @@ import java.io.IOException;
|
|||
|
||||
/**
|
||||
* RunListener that will be called when a build starts and completes.
|
||||
* Will lookup GitLabPushTrigger and call set the build description if necessary.
|
||||
* Will lookup GiteePushTrigger and call set the build description if necessary.
|
||||
*
|
||||
* @author Robin Müller
|
||||
*/
|
||||
@Extension
|
||||
public class GitLabBuildDescriptionRunListener extends RunListener<Run<?, ?>> {
|
||||
public class GiteeBuildDescriptionRunListener extends RunListener<Run<?, ?>> {
|
||||
|
||||
@Override
|
||||
public void onStarted(Run<?, ?> build, TaskListener listener) {
|
||||
GitLabPushTrigger trigger = GitLabPushTrigger.getFromJob(build.getParent());
|
||||
GiteePushTrigger trigger = GiteePushTrigger.getFromJob(build.getParent());
|
||||
if (trigger != null && trigger.getSetBuildDescription()) {
|
||||
Cause cause = build.getCause(GiteeWebHookCause.class);
|
||||
if (cause != null && !cause.getShortDescription().isEmpty()) {
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.publisher;
|
||||
package com.dabsquared.giteejenkins.publisher;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.MergeRequest;
|
||||
import hudson.Extension;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Result;
|
||||
|
@ -21,11 +21,11 @@ import java.util.logging.Logger;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public class GitLabAcceptMergeRequestPublisher extends MergeRequestNotifier {
|
||||
private static final Logger LOGGER = Logger.getLogger(GitLabAcceptMergeRequestPublisher.class.getName());
|
||||
public class GiteeAcceptMergeRequestPublisher extends MergeRequestNotifier {
|
||||
private static final Logger LOGGER = Logger.getLogger(GiteeAcceptMergeRequestPublisher.class.getName());
|
||||
|
||||
@DataBoundConstructor
|
||||
public GitLabAcceptMergeRequestPublisher() { }
|
||||
public GiteeAcceptMergeRequestPublisher() { }
|
||||
|
||||
public BuildStepMonitor getRequiredMonitorService() {
|
||||
return BuildStepMonitor.NONE;
|
||||
|
@ -46,7 +46,7 @@ public class GitLabAcceptMergeRequestPublisher extends MergeRequestNotifier {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GitLabClient client, MergeRequest mergeRequest) {
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, MergeRequest mergeRequest) {
|
||||
try {
|
||||
if (build.getResult() == Result.SUCCESS) {
|
||||
client.acceptMergeRequest(mergeRequest, "Merge Request accepted by jenkins build success", false);
|
|
@ -1,7 +1,7 @@
|
|||
package com.dabsquared.gitlabjenkins.publisher;
|
||||
package com.dabsquared.giteejenkins.publisher;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.BuildState;
|
||||
import com.dabsquared.gitlabjenkins.util.CommitStatusUpdater;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.BuildState;
|
||||
import com.dabsquared.giteejenkins.util.CommitStatusUpdater;
|
||||
import hudson.Extension;
|
||||
import hudson.Launcher;
|
||||
import hudson.matrix.MatrixAggregatable;
|
||||
|
@ -25,13 +25,13 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public class GitLabCommitStatusPublisher extends Notifier implements MatrixAggregatable {
|
||||
public class GiteeCommitStatusPublisher extends Notifier implements MatrixAggregatable {
|
||||
|
||||
private String name;
|
||||
private boolean markUnstableAsSuccess;
|
||||
|
||||
@DataBoundConstructor
|
||||
public GitLabCommitStatusPublisher(String name, boolean markUnstableAsSuccess) {
|
||||
public GiteeCommitStatusPublisher(String name, boolean markUnstableAsSuccess) {
|
||||
this.name = name;
|
||||
this.markUnstableAsSuccess = markUnstableAsSuccess;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class GitLabCommitStatusPublisher extends Notifier implements MatrixAggre
|
|||
return markUnstableAsSuccess;
|
||||
}
|
||||
|
||||
protected GitLabCommitStatusPublisher readResolve() {
|
||||
protected GiteeCommitStatusPublisher readResolve() {
|
||||
if (name == null) {
|
||||
name = "jenkins";
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class GitLabCommitStatusPublisher extends Notifier implements MatrixAggre
|
|||
|
||||
@Override
|
||||
public String getHelpFile() {
|
||||
return "/plugin/gitlab-plugin/help/help-send-result-to-gitlab.html";
|
||||
return "/plugin/gitee-plugin/help/help-send-result-to-gitee.html";
|
||||
}
|
||||
|
||||
public FormValidation doCheckName(@QueryParameter String value) {
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.publisher;
|
||||
package com.dabsquared.giteejenkins.publisher;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.MergeRequest;
|
||||
import hudson.Extension;
|
||||
import hudson.Util;
|
||||
import hudson.model.AbstractProject;
|
||||
|
@ -26,8 +26,8 @@ import java.util.logging.Logger;
|
|||
/**
|
||||
* @author Nikolay Ustinov
|
||||
*/
|
||||
public class GitLabMessagePublisher extends MergeRequestNotifier {
|
||||
private static final Logger LOGGER = Logger.getLogger(GitLabMessagePublisher.class.getName());
|
||||
public class GiteeMessagePublisher extends MergeRequestNotifier {
|
||||
private static final Logger LOGGER = Logger.getLogger(GiteeMessagePublisher.class.getName());
|
||||
private boolean onlyForFailure = false;
|
||||
private boolean replaceSuccessNote = false;
|
||||
private boolean replaceFailureNote = false;
|
||||
|
@ -39,11 +39,11 @@ public class GitLabMessagePublisher extends MergeRequestNotifier {
|
|||
private String unstableNoteText;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #GitLabMessagePublisher()} with setters to configure an instance of this class.
|
||||
* @deprecated use {@link #GiteeMessagePublisher()} with setters to configure an instance of this class.
|
||||
*/
|
||||
@Deprecated
|
||||
public GitLabMessagePublisher(boolean onlyForFailure, boolean replaceSuccessNote, boolean replaceFailureNote, boolean replaceAbortNote, boolean replaceUnstableNote,
|
||||
String successNoteText, String failureNoteText, String abortNoteText, String unstableNoteText) {
|
||||
public GiteeMessagePublisher(boolean onlyForFailure, boolean replaceSuccessNote, boolean replaceFailureNote, boolean replaceAbortNote, boolean replaceUnstableNote,
|
||||
String successNoteText, String failureNoteText, String abortNoteText, String unstableNoteText) {
|
||||
this.onlyForFailure = onlyForFailure;
|
||||
this.replaceSuccessNote = replaceSuccessNote;
|
||||
this.replaceFailureNote = replaceFailureNote;
|
||||
|
@ -56,7 +56,7 @@ public class GitLabMessagePublisher extends MergeRequestNotifier {
|
|||
}
|
||||
|
||||
@DataBoundConstructor
|
||||
public GitLabMessagePublisher() { }
|
||||
public GiteeMessagePublisher() { }
|
||||
|
||||
public boolean isOnlyForFailure() {
|
||||
return onlyForFailure;
|
||||
|
@ -154,12 +154,12 @@ public class GitLabMessagePublisher extends MergeRequestNotifier {
|
|||
|
||||
@Override
|
||||
public String getHelpFile() {
|
||||
return "/plugin/gitlab-plugin/help/help-messagesOnResult.html";
|
||||
return "/plugin/gitee-plugin/help/help-messagesOnResult.html";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GitLabClient client, MergeRequest mergeRequest) {
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, MergeRequest mergeRequest) {
|
||||
try {
|
||||
if (!onlyForFailure || build.getResult() == Result.FAILURE || build.getResult() == Result.UNSTABLE) {
|
||||
client.createMergeRequestNote(mergeRequest, getNote(build, listener));
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.publisher;
|
||||
package com.dabsquared.giteejenkins.publisher;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.MergeRequest;
|
||||
import hudson.Extension;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Result;
|
||||
|
@ -21,11 +21,11 @@ import java.util.logging.Logger;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public class GitLabVotePublisher extends MergeRequestNotifier {
|
||||
private static final Logger LOGGER = Logger.getLogger(GitLabVotePublisher.class.getName());
|
||||
public class GiteeVotePublisher extends MergeRequestNotifier {
|
||||
private static final Logger LOGGER = Logger.getLogger(GiteeVotePublisher.class.getName());
|
||||
|
||||
@DataBoundConstructor
|
||||
public GitLabVotePublisher() { }
|
||||
public GiteeVotePublisher() { }
|
||||
|
||||
public BuildStepMonitor getRequiredMonitorService() {
|
||||
return BuildStepMonitor.NONE;
|
||||
|
@ -46,7 +46,7 @@ public class GitLabVotePublisher extends MergeRequestNotifier {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GitLabClient client, MergeRequest mergeRequest) {
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, MergeRequest mergeRequest) {
|
||||
try {
|
||||
client.createMergeRequestNote(mergeRequest, getResultIcon(build.getResult()));
|
||||
} catch (WebApplicationException | ProcessingException e) {
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.publisher;
|
||||
package com.dabsquared.giteejenkins.publisher;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
|
||||
import com.dabsquared.giteejenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.MergeRequest;
|
||||
import hudson.Launcher;
|
||||
import hudson.matrix.MatrixAggregatable;
|
||||
import hudson.matrix.MatrixAggregator;
|
||||
|
@ -16,7 +16,7 @@ import hudson.tasks.Notifier;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient;
|
||||
import static com.dabsquared.giteejenkins.connection.GiteeConnectionProperty.getClient;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
|
@ -28,7 +28,7 @@ public abstract class MergeRequestNotifier extends Notifier implements MatrixAgg
|
|||
|
||||
@Override
|
||||
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
|
||||
GitLabClient client = getClient(build);
|
||||
GiteeClient client = getClient(build);
|
||||
if (client == null) {
|
||||
listener.getLogger().println("No GitLab connection configured");
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@ public abstract class MergeRequestNotifier extends Notifier implements MatrixAgg
|
|||
};
|
||||
}
|
||||
|
||||
protected abstract void perform(Run<?, ?> build, TaskListener listener, GitLabClient client, MergeRequest mergeRequest);
|
||||
protected abstract void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, MergeRequest mergeRequest);
|
||||
|
||||
MergeRequest getMergeRequest(Run<?, ?> run) {
|
||||
GiteeWebHookCause cause = run.getCause(GiteeWebHookCause.class);
|
|
@ -1,10 +1,10 @@
|
|||
package com.dabsquared.gitlabjenkins.service;
|
||||
package com.dabsquared.giteejenkins.service;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.Branch;
|
||||
import com.dabsquared.gitlabjenkins.util.LoggerUtil;
|
||||
import com.dabsquared.gitlabjenkins.util.ProjectIdUtil;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.Branch;
|
||||
import com.dabsquared.giteejenkins.util.LoggerUtil;
|
||||
import com.dabsquared.giteejenkins.util.ProjectIdUtil;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
|
@ -17,28 +17,28 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class GitLabProjectBranchesService {
|
||||
public class GiteeProjectBranchesService {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GitLabProjectBranchesService.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(GiteeProjectBranchesService.class.getName());
|
||||
|
||||
private static transient GitLabProjectBranchesService gitLabProjectBranchesService;
|
||||
private static transient GiteeProjectBranchesService giteeProjectBranchesService;
|
||||
private final Cache<String, List<String>> projectBranchCache;
|
||||
|
||||
GitLabProjectBranchesService() {
|
||||
GiteeProjectBranchesService() {
|
||||
this.projectBranchCache = CacheBuilder.<String, String>newBuilder()
|
||||
.maximumSize(1000)
|
||||
.expireAfterWrite(5, TimeUnit.SECONDS)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static GitLabProjectBranchesService instance() {
|
||||
if (gitLabProjectBranchesService == null) {
|
||||
gitLabProjectBranchesService = new GitLabProjectBranchesService();
|
||||
public static GiteeProjectBranchesService instance() {
|
||||
if (giteeProjectBranchesService == null) {
|
||||
giteeProjectBranchesService = new GiteeProjectBranchesService();
|
||||
}
|
||||
return gitLabProjectBranchesService;
|
||||
return giteeProjectBranchesService;
|
||||
}
|
||||
|
||||
public List<String> getBranches(GitLabClient client, String sourceRepositoryString) {
|
||||
public List<String> getBranches(GiteeClient client, String sourceRepositoryString) {
|
||||
synchronized (projectBranchCache) {
|
||||
try {
|
||||
return projectBranchCache.get(sourceRepositoryString, new BranchNamesLoader(client, sourceRepositoryString));
|
||||
|
@ -55,10 +55,10 @@ public class GitLabProjectBranchesService {
|
|||
}
|
||||
|
||||
private static class BranchNamesLoader implements Callable<List<String>> {
|
||||
private final GitLabClient client;
|
||||
private final GiteeClient client;
|
||||
private final String sourceRepository;
|
||||
|
||||
private BranchNamesLoader(GitLabClient client, String sourceRepository) {
|
||||
private BranchNamesLoader(GiteeClient client, String sourceRepository) {
|
||||
this.client = client;
|
||||
this.sourceRepository = sourceRepository;
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package com.dabsquared.gitlabjenkins.service;
|
||||
package com.dabsquared.giteejenkins.service;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.Label;
|
||||
import com.dabsquared.gitlabjenkins.util.LoggerUtil;
|
||||
import com.dabsquared.gitlabjenkins.util.ProjectIdUtil;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.Label;
|
||||
import com.dabsquared.giteejenkins.util.LoggerUtil;
|
||||
import com.dabsquared.giteejenkins.util.ProjectIdUtil;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
|
@ -17,28 +17,28 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class GitLabProjectLabelsService {
|
||||
public class GiteeProjectLabelsService {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GitLabProjectLabelsService.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(GiteeProjectLabelsService.class.getName());
|
||||
|
||||
private static transient GitLabProjectLabelsService instance;
|
||||
private static transient GiteeProjectLabelsService instance;
|
||||
private final Cache<String, List<String>> projectLabelsCache;
|
||||
|
||||
GitLabProjectLabelsService() {
|
||||
GiteeProjectLabelsService() {
|
||||
this.projectLabelsCache = CacheBuilder.<String, String>newBuilder()
|
||||
.maximumSize(1000)
|
||||
.expireAfterWrite(5, TimeUnit.SECONDS)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static GitLabProjectLabelsService instance() {
|
||||
public static GiteeProjectLabelsService instance() {
|
||||
if (instance == null) {
|
||||
instance = new GitLabProjectLabelsService();
|
||||
instance = new GiteeProjectLabelsService();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public List<String> getLabels(GitLabClient client, String sourceRepositoryString) {
|
||||
public List<String> getLabels(GiteeClient client, String sourceRepositoryString) {
|
||||
synchronized (projectLabelsCache) {
|
||||
try {
|
||||
return projectLabelsCache.get(sourceRepositoryString, new LabelNamesLoader(client, sourceRepositoryString));
|
||||
|
@ -55,10 +55,10 @@ public class GitLabProjectLabelsService {
|
|||
}
|
||||
|
||||
private static class LabelNamesLoader implements Callable<List<String>> {
|
||||
private final GitLabClient client;
|
||||
private final GiteeClient client;
|
||||
private final String sourceRepository;
|
||||
|
||||
private LabelNamesLoader(GitLabClient client, String sourceRepository) {
|
||||
private LabelNamesLoader(GiteeClient client, String sourceRepository) {
|
||||
this.client = client;
|
||||
this.sourceRepository = sourceRepository;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger;
|
||||
package com.dabsquared.giteejenkins.trigger;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.branch;
|
||||
package com.dabsquared.giteejenkins.trigger.branch;
|
||||
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.branch;
|
||||
package com.dabsquared.giteejenkins.trigger.branch;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.Messages;
|
||||
import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty;
|
||||
import com.dabsquared.gitlabjenkins.service.GitLabProjectBranchesService;
|
||||
import com.dabsquared.giteejenkins.Messages;
|
||||
import com.dabsquared.giteejenkins.connection.GiteeConnectionProperty;
|
||||
import com.dabsquared.giteejenkins.service.GiteeProjectBranchesService;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import hudson.model.AutoCompletionCandidates;
|
||||
|
@ -43,9 +43,9 @@ public final class ProjectBranchesProvider {
|
|||
|
||||
private List<String> getProjectBranches(Job<?, ?> project) {
|
||||
final URIish sourceRepository = getSourceRepoURLDefault(project);
|
||||
GitLabConnectionProperty connectionProperty = project.getProperty(GitLabConnectionProperty.class);
|
||||
GiteeConnectionProperty connectionProperty = project.getProperty(GiteeConnectionProperty.class);
|
||||
if (connectionProperty != null && connectionProperty.getClient() != null) {
|
||||
return GitLabProjectBranchesService.instance().getBranches(connectionProperty.getClient(), sourceRepository.toString());
|
||||
return GiteeProjectBranchesService.instance().getBranches(connectionProperty.getClient(), sourceRepository.toString());
|
||||
} else {
|
||||
LOGGER.log(Level.WARNING, "getProjectBranches: gitlabHostUrl hasn't been configured globally. Job {0}.", project.getFullName());
|
||||
return Collections.emptyList();
|
||||
|
@ -74,7 +74,7 @@ public final class ProjectBranchesProvider {
|
|||
|
||||
try {
|
||||
return checkMatchingBranches(value, getProjectBranches(project));
|
||||
} catch (GitLabProjectBranchesService.BranchLoadingException e) {
|
||||
} catch (GiteeProjectBranchesService.BranchLoadingException e) {
|
||||
return FormValidation.warning(project.hasPermission(Jenkins.ADMINISTER) ? e : null, Messages.GitLabPushTrigger_CannotCheckBranches());
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public final class ProjectBranchesProvider {
|
|||
try {
|
||||
List<String> branches = getProjectBranches(job);
|
||||
return branches.toArray(new String[branches.size()]);
|
||||
} catch (GitLabProjectBranchesService.BranchLoadingException e) {
|
||||
} catch (GiteeProjectBranchesService.BranchLoadingException e) {
|
||||
LOGGER.log(Level.FINEST, "Failed to load branch names from GitLab. Please check the logs and your configuration.", e);
|
||||
}
|
||||
return new String[0];
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.exception;
|
||||
package com.dabsquared.giteejenkins.trigger.exception;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
import org.kohsuke.stapler.DataBoundSetter;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import org.springframework.util.AntPathMatcher;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.filter;
|
||||
package com.dabsquared.giteejenkins.trigger.filter;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler;
|
||||
package com.dabsquared.giteejenkins.trigger.handler;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.cause.CauseData;
|
||||
import com.dabsquared.gitlabjenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.BuildState;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.WebHook;
|
||||
import com.dabsquared.gitlabjenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.gitlabjenkins.util.LoggerUtil;
|
||||
import com.dabsquared.giteejenkins.cause.CauseData;
|
||||
import com.dabsquared.giteejenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.giteejenkins.connection.GiteeConnectionProperty;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.BuildState;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.WebHook;
|
||||
import com.dabsquared.giteejenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.util.LoggerUtil;
|
||||
import hudson.model.Action;
|
||||
import hudson.model.CauseAction;
|
||||
import hudson.model.Job;
|
||||
|
@ -63,7 +63,7 @@ public abstract class AbstractWebHookTriggerHandler<H extends WebHook> implement
|
|||
private void setCommitStatusPendingIfNecessary(Job<?, ?> job, H hook) {
|
||||
String buildName = PendingBuildsHandler.resolvePendingBuildName(job);
|
||||
if (StringUtils.isNotBlank(buildName)) {
|
||||
GitLabClient client = job.getProperty(GitLabConnectionProperty.class).getClient();
|
||||
GiteeClient client = job.getProperty(GiteeConnectionProperty.class).getClient();
|
||||
BuildStatusUpdate buildStatusUpdate = retrieveBuildStatusUpdate(hook);
|
||||
try {
|
||||
if (client == null) {
|
|
@ -1,13 +1,13 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler;
|
||||
package com.dabsquared.giteejenkins.trigger.handler;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.GitLabPushTrigger;
|
||||
import com.dabsquared.gitlabjenkins.cause.CauseData;
|
||||
import com.dabsquared.gitlabjenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.BuildState;
|
||||
import com.dabsquared.gitlabjenkins.publisher.GitLabCommitStatusPublisher;
|
||||
import com.dabsquared.gitlabjenkins.util.LoggerUtil;
|
||||
import com.dabsquared.giteejenkins.GiteePushTrigger;
|
||||
import com.dabsquared.giteejenkins.cause.CauseData;
|
||||
import com.dabsquared.giteejenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.giteejenkins.connection.GiteeConnectionProperty;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.BuildState;
|
||||
import com.dabsquared.giteejenkins.publisher.GiteeCommitStatusPublisher;
|
||||
import com.dabsquared.giteejenkins.util.LoggerUtil;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Cause;
|
||||
import hudson.model.Job;
|
||||
|
@ -69,7 +69,7 @@ public class PendingBuildsHandler {
|
|||
return;
|
||||
}
|
||||
String targetUrl = DisplayURLProvider.get().getJobURL(job);
|
||||
GitLabClient client = job.getProperty(GitLabConnectionProperty.class).getClient();
|
||||
GiteeClient client = job.getProperty(GiteeConnectionProperty.class).getClient();
|
||||
try {
|
||||
client.changeBuildStatus(causeData.getSourceProjectId(), causeData.getLastCommit(), BuildState.canceled,
|
||||
causeData.getSourceBranch(), buildName, targetUrl, BuildState.canceled.name());
|
||||
|
@ -80,13 +80,13 @@ public class PendingBuildsHandler {
|
|||
|
||||
public static String resolvePendingBuildName(Job<?, ?> job) {
|
||||
if (job instanceof AbstractProject) {
|
||||
GitLabCommitStatusPublisher publisher =
|
||||
(GitLabCommitStatusPublisher) ((AbstractProject) job).getPublishersList().get(GitLabCommitStatusPublisher.class);
|
||||
GiteeCommitStatusPublisher publisher =
|
||||
(GiteeCommitStatusPublisher) ((AbstractProject) job).getPublishersList().get(GiteeCommitStatusPublisher.class);
|
||||
if (publisher != null) {
|
||||
return publisher.getName();
|
||||
}
|
||||
} else if (job instanceof WorkflowJob) {
|
||||
GitLabPushTrigger trigger = GitLabPushTrigger.getFromJob(job);
|
||||
GiteePushTrigger trigger = GiteePushTrigger.getFromJob(job);
|
||||
if (trigger != null) {
|
||||
return trigger.getPendingBuildName();
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.dabsquared.giteejenkins.trigger.handler;
|
||||
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.WebHook;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import hudson.model.Job;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public interface WebHookTriggerHandler<H extends WebHook> {
|
||||
|
||||
void handle(Job<?, ?> job, H hook, boolean ciSkip, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.dabsquared.giteejenkins.trigger.handler.merge;
|
||||
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.MergeRequestHook;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.WebHookTriggerHandler;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public interface MergeRequestHookTriggerHandler extends WebHookTriggerHandler<MergeRequestHook> { }
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.merge;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.merge;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.Action;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.gitlabjenkins.trigger.TriggerOpenMergeRequest;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.Action;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.trigger.TriggerOpenMergeRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
|
@ -1,18 +1,17 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.merge;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.merge;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.cause.CauseData;
|
||||
import com.dabsquared.gitlabjenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.Action;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestHook;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestObjectAttributes;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestLabel;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.gitlabjenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||
import com.dabsquared.gitlabjenkins.util.BuildUtil;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.PendingBuildsHandler;
|
||||
import com.dabsquared.giteejenkins.cause.CauseData;
|
||||
import com.dabsquared.giteejenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.Action;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.MergeRequestHook;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.MergeRequestObjectAttributes;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.MergeRequestLabel;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||
import com.dabsquared.giteejenkins.util.BuildUtil;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Run;
|
||||
import hudson.plugins.git.GitSCM;
|
||||
|
@ -26,9 +25,9 @@ import java.util.EnumSet;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.gitlabjenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||
import static com.dabsquared.gitlabjenkins.util.LoggerUtil.toArray;
|
||||
import static com.dabsquared.giteejenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.giteejenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||
import static com.dabsquared.giteejenkins.util.LoggerUtil.toArray;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.merge;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.merge;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestHook;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.MergeRequestHook;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import hudson.model.Job;
|
||||
|
||||
/**
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.note;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.note;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.NoteHook;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.NoteHook;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import hudson.model.Job;
|
||||
|
||||
/**
|
|
@ -0,0 +1,9 @@
|
|||
package com.dabsquared.giteejenkins.trigger.handler.note;
|
||||
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.NoteHook;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.WebHookTriggerHandler;
|
||||
|
||||
/**
|
||||
* @author Nikolay Ustinov
|
||||
*/
|
||||
public interface NoteHookTriggerHandler extends WebHookTriggerHandler<NoteHook> { }
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.note;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.note;
|
||||
|
||||
/**
|
||||
* @author Nikolay Ustinov
|
|
@ -1,11 +1,11 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.note;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.note;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.cause.CauseData;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.NoteHook;
|
||||
import com.dabsquared.gitlabjenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||
import com.dabsquared.giteejenkins.cause.CauseData;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.NoteHook;
|
||||
import com.dabsquared.giteejenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||
import hudson.model.Job;
|
||||
import hudson.plugins.git.GitSCM;
|
||||
import hudson.plugins.git.RevisionParameterAction;
|
||||
|
@ -14,8 +14,8 @@ import org.apache.commons.lang.StringUtils;
|
|||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.gitlabjenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||
import static com.dabsquared.giteejenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.giteejenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||
|
||||
/**
|
||||
* @author Nikolay Ustinov
|
|
@ -0,0 +1,17 @@
|
|||
package com.dabsquared.giteejenkins.trigger.handler.pipeline;
|
||||
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PipelineHook;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import hudson.model.Job;
|
||||
|
||||
/**
|
||||
* @author Milena Zachow
|
||||
*/
|
||||
class NopPipelineHookTriggerHandler implements PipelineHookTriggerHandler {
|
||||
|
||||
@Override
|
||||
public void handle(Job<?, ?> job, PipelineHook hook, boolean ciSkip, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.dabsquared.giteejenkins.trigger.handler.pipeline;
|
||||
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PipelineHook;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.WebHookTriggerHandler;
|
||||
|
||||
/**
|
||||
* @author Milena Zachow
|
||||
*/
|
||||
public interface PipelineHookTriggerHandler extends WebHookTriggerHandler<PipelineHook> { }
|
|
@ -1,6 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.pipeline;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.pipeline;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,17 +1,17 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.pipeline;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.pipeline;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.cause.CauseData;
|
||||
import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.PipelineEventObjectAttributes;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.PipelineHook;
|
||||
import com.dabsquared.gitlabjenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||
import com.dabsquared.gitlabjenkins.util.BuildUtil;
|
||||
import com.dabsquared.gitlabjenkins.util.LoggerUtil;
|
||||
import com.dabsquared.giteejenkins.cause.CauseData;
|
||||
import com.dabsquared.giteejenkins.connection.GiteeConnectionProperty;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PipelineEventObjectAttributes;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PipelineHook;
|
||||
import com.dabsquared.giteejenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||
import com.dabsquared.giteejenkins.util.BuildUtil;
|
||||
import com.dabsquared.giteejenkins.util.LoggerUtil;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Run;
|
||||
|
@ -23,8 +23,8 @@ import java.util.List;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.gitlabjenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||
import static com.dabsquared.giteejenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.giteejenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||
|
||||
/**
|
||||
* @author Milena Zachow
|
||||
|
@ -44,16 +44,16 @@ class PipelineHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<Pipel
|
|||
PipelineEventObjectAttributes objectAttributes = hook.getObjectAttributes();
|
||||
try {
|
||||
if (job instanceof AbstractProject<?, ?>) {
|
||||
GitLabConnectionProperty property = job.getProperty(GitLabConnectionProperty.class);
|
||||
GiteeConnectionProperty property = job.getProperty(GiteeConnectionProperty.class);
|
||||
|
||||
if (property != null && property.getClient() != null) {
|
||||
GitLabClient client = property.getClient();
|
||||
com.dabsquared.gitlabjenkins.gitlab.api.model.Project projectForName = client.getProject(hook.getProject().getPathWithNamespace());
|
||||
GiteeClient client = property.getClient();
|
||||
com.dabsquared.giteejenkins.gitee.api.model.Project projectForName = client.getProject(hook.getProject().getPathWithNamespace());
|
||||
hook.setProjectId(projectForName.getId());
|
||||
}
|
||||
}
|
||||
} catch (WebApplicationException e) {
|
||||
LOGGER.log(Level.WARNING, "Failed to communicate with gitlab server to determine project id: " + e.getMessage(), e);
|
||||
LOGGER.log(Level.WARNING, "Failed to communicate with gitee server to determine project id: " + e.getMessage(), e);
|
||||
}
|
||||
if (allowedStates.contains(objectAttributes.getStatus()) && !isLastAlreadyBuild(job,hook)) {
|
||||
if (ciSkip && isCiSkip(hook)) {
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.push;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.push;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.PushHook;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PushHook;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import hudson.model.Job;
|
||||
|
||||
/**
|
|
@ -1,21 +1,21 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.push;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.push;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.GitLabPushTrigger;
|
||||
import com.dabsquared.gitlabjenkins.cause.CauseData;
|
||||
import com.dabsquared.gitlabjenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.Branch;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.BuildState;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.Project;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.PushHook;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.State;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.gitlabjenkins.util.LoggerUtil;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.PendingBuildsHandler;
|
||||
import com.dabsquared.giteejenkins.GiteePushTrigger;
|
||||
import com.dabsquared.giteejenkins.cause.CauseData;
|
||||
import com.dabsquared.giteejenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.giteejenkins.connection.GiteeConnectionProperty;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.Branch;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.BuildState;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.MergeRequest;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.Project;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PushHook;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.State;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.util.LoggerUtil;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.PendingBuildsHandler;
|
||||
import hudson.model.Action;
|
||||
import hudson.model.CauseAction;
|
||||
import hudson.model.Job;
|
||||
|
@ -36,8 +36,8 @@ import java.util.List;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.gitlabjenkins.util.LoggerUtil.toArray;
|
||||
import static com.dabsquared.giteejenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.giteejenkins.util.LoggerUtil.toArray;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
|
@ -57,13 +57,13 @@ class OpenMergeRequestPushHookTriggerHandler implements PushHookTriggerHandler {
|
|||
try {
|
||||
if (job instanceof ParameterizedJobMixIn.ParameterizedJob) {
|
||||
ParameterizedJob project = (ParameterizedJobMixIn.ParameterizedJob) job;
|
||||
GitLabConnectionProperty property = job.getProperty(GitLabConnectionProperty.class);
|
||||
GiteeConnectionProperty property = job.getProperty(GiteeConnectionProperty.class);
|
||||
for (Trigger t : project.getTriggers().values()) {
|
||||
if (t instanceof GitLabPushTrigger) {
|
||||
final GitLabPushTrigger trigger = (GitLabPushTrigger) t;
|
||||
if (t instanceof GiteePushTrigger) {
|
||||
final GiteePushTrigger trigger = (GiteePushTrigger) t;
|
||||
Integer projectId = hook.getProjectId();
|
||||
if (property != null && property.getClient() != null && projectId != null && trigger != null) {
|
||||
GitLabClient client = property.getClient();
|
||||
GiteeClient client = property.getClient();
|
||||
for (MergeRequest mergeRequest : getOpenMergeRequests(client, projectId.toString())) {
|
||||
if (mergeRequestLabelFilter.isMergeRequestAllowed(mergeRequest.getLabels())) {
|
||||
handleMergeRequest(job, hook, ciSkip, branchFilter, client, mergeRequest);
|
||||
|
@ -77,11 +77,11 @@ class OpenMergeRequestPushHookTriggerHandler implements PushHookTriggerHandler {
|
|||
LOGGER.log(Level.FINE, "Not a ParameterizedJob: {0}",LoggerUtil.toArray(job.getClass().getName()));
|
||||
}
|
||||
} catch (WebApplicationException | ProcessingException e) {
|
||||
LOGGER.log(Level.WARNING, "Failed to communicate with gitlab server to determine if this is an update for a merge request: " + e.getMessage(), e);
|
||||
LOGGER.log(Level.WARNING, "Failed to communicate with gitee server to determine if this is an update for a merge request: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<MergeRequest> getOpenMergeRequests(GitLabClient client, String projectId) {
|
||||
private List<MergeRequest> getOpenMergeRequests(GiteeClient client, String projectId) {
|
||||
List<MergeRequest> result = new ArrayList<>();
|
||||
Integer page = 1;
|
||||
do {
|
||||
|
@ -92,7 +92,7 @@ class OpenMergeRequestPushHookTriggerHandler implements PushHookTriggerHandler {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void handleMergeRequest(Job<?, ?> job, PushHook hook, boolean ciSkip, BranchFilter branchFilter, GitLabClient client, MergeRequest mergeRequest) {
|
||||
private void handleMergeRequest(Job<?, ?> job, PushHook hook, boolean ciSkip, BranchFilter branchFilter, GiteeClient client, MergeRequest mergeRequest) {
|
||||
if (ciSkip && mergeRequest.getDescription() != null && mergeRequest.getDescription().contains("[ci-skip]")) {
|
||||
LOGGER.log(Level.INFO, "Skipping MR " + mergeRequest.getTitle() + " due to ci-skip.");
|
||||
return;
|
||||
|
@ -154,7 +154,7 @@ class OpenMergeRequestPushHookTriggerHandler implements PushHookTriggerHandler {
|
|||
private void setCommitStatusPendingIfNecessary(Job<?, ?> job, Integer projectId, String commit, String ref) {
|
||||
String buildName = PendingBuildsHandler.resolvePendingBuildName(job);
|
||||
if (StringUtils.isNotBlank(buildName)) {
|
||||
GitLabClient client = job.getProperty(GitLabConnectionProperty.class).getClient();
|
||||
GiteeClient client = job.getProperty(GiteeConnectionProperty.class).getClient();
|
||||
try {
|
||||
String targetUrl = DisplayURLProvider.get().getJobURL(job);
|
||||
client.changeBuildStatus(projectId, commit, BuildState.pending, ref, buildName, targetUrl, BuildState.pending.name());
|
|
@ -0,0 +1,9 @@
|
|||
package com.dabsquared.giteejenkins.trigger.handler.push;
|
||||
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PushHook;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.WebHookTriggerHandler;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public interface PushHookTriggerHandler extends WebHookTriggerHandler<PushHook> { }
|
|
@ -1,6 +1,6 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.push;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.push;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.trigger.TriggerOpenMergeRequest;
|
||||
import com.dabsquared.giteejenkins.trigger.TriggerOpenMergeRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,12 +1,12 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.push;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.push;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.cause.CauseData;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.Commit;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.PushHook;
|
||||
import com.dabsquared.gitlabjenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||
import com.dabsquared.giteejenkins.cause.CauseData;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.Commit;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PushHook;
|
||||
import com.dabsquared.giteejenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||
import hudson.model.Job;
|
||||
import hudson.plugins.git.GitSCM;
|
||||
import hudson.plugins.git.RevisionParameterAction;
|
||||
|
@ -14,8 +14,8 @@ import org.eclipse.jgit.util.StringUtils;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.gitlabjenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||
import static com.dabsquared.giteejenkins.cause.CauseDataBuilder.causeData;
|
||||
import static com.dabsquared.giteejenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
|
@ -1,8 +1,8 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.handler.push;
|
||||
package com.dabsquared.giteejenkins.trigger.handler.push;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.PushHook;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.gitlabjenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.dabsquared.giteejenkins.gitee.hook.model.PushHook;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.BranchFilter;
|
||||
import com.dabsquared.giteejenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import hudson.model.Job;
|
||||
|
||||
import java.util.List;
|
|
@ -1,9 +1,9 @@
|
|||
package com.dabsquared.gitlabjenkins.trigger.label;
|
||||
package com.dabsquared.giteejenkins.trigger.label;
|
||||
|
||||
import com.dabsquared.gitlabjenkins.Messages;
|
||||
import com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty;
|
||||
import com.dabsquared.gitlabjenkins.service.GitLabProjectBranchesService;
|
||||
import com.dabsquared.gitlabjenkins.service.GitLabProjectLabelsService;
|
||||
import com.dabsquared.giteejenkins.Messages;
|
||||
import com.dabsquared.giteejenkins.connection.GiteeConnectionProperty;
|
||||
import com.dabsquared.giteejenkins.service.GiteeProjectBranchesService;
|
||||
import com.dabsquared.giteejenkins.service.GiteeProjectLabelsService;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import hudson.model.AutoCompletionCandidates;
|
||||
|
@ -44,9 +44,9 @@ public final class ProjectLabelsProvider {
|
|||
|
||||
private List<String> getProjectLabels(Job<?, ?> project) {
|
||||
final URIish sourceRepository = getSourceRepoURLDefault(project);
|
||||
GitLabConnectionProperty connectionProperty = project.getProperty(GitLabConnectionProperty.class);
|
||||
GiteeConnectionProperty connectionProperty = project.getProperty(GiteeConnectionProperty.class);
|
||||
if (connectionProperty != null && connectionProperty.getClient() != null) {
|
||||
return GitLabProjectLabelsService.instance().getLabels(connectionProperty.getClient(), sourceRepository.toString());
|
||||
return GiteeProjectLabelsService.instance().getLabels(connectionProperty.getClient(), sourceRepository.toString());
|
||||
} else {
|
||||
LOGGER.log(Level.WARNING, "getProjectLabels: gitlabHostUrl hasn't been configured globally. Job {0}.", project.getFullName());
|
||||
return Collections.emptyList();
|
||||
|
@ -75,7 +75,7 @@ public final class ProjectLabelsProvider {
|
|||
|
||||
try {
|
||||
return checkMatchingLabels(value, getProjectLabels(project));
|
||||
} catch (GitLabProjectBranchesService.BranchLoadingException e) {
|
||||
} catch (GiteeProjectBranchesService.BranchLoadingException e) {
|
||||
return FormValidation.warning(project.hasPermission(Jenkins.ADMINISTER) ? e : null, Messages.GitLabPushTrigger_CannotCheckBranches());
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public final class ProjectLabelsProvider {
|
|||
try {
|
||||
List<String> labels = getProjectLabels(job);
|
||||
return labels.toArray(new String[labels.size()]);
|
||||
} catch (GitLabProjectLabelsService.LabelLoadingException e) {
|
||||
} catch (GiteeProjectLabelsService.LabelLoadingException e) {
|
||||
LOGGER.log(Level.FINEST, "Failed to load labels from GitLab. Please check the logs and your configuration.", e);
|
||||
}
|
||||
return new String[0];
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.util;
|
||||
package com.dabsquared.giteejenkins.util;
|
||||
|
||||
import hudson.security.ACL;
|
||||
import org.acegisecurity.Authentication;
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.util;
|
||||
package com.dabsquared.giteejenkins.util;
|
||||
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Run;
|
|
@ -1,9 +1,9 @@
|
|||
package com.dabsquared.gitlabjenkins.util;
|
||||
package com.dabsquared.giteejenkins.util;
|
||||
|
||||
|
||||
import com.dabsquared.gitlabjenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.GitLabClient;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.api.model.BuildState;
|
||||
import com.dabsquared.giteejenkins.cause.GiteeWebHookCause;
|
||||
import com.dabsquared.giteejenkins.gitee.api.GiteeClient;
|
||||
import com.dabsquared.giteejenkins.gitee.api.model.BuildState;
|
||||
import hudson.EnvVars;
|
||||
import hudson.model.Cause;
|
||||
import hudson.model.Run;
|
||||
|
@ -12,7 +12,6 @@ import hudson.model.Cause.UpstreamCause;
|
|||
import hudson.plugins.git.Revision;
|
||||
import hudson.plugins.git.util.Build;
|
||||
import hudson.plugins.git.util.BuildData;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.plugins.git.AbstractGitSCMSource;
|
||||
import jenkins.scm.api.SCMRevision;
|
||||
import jenkins.scm.api.SCMRevisionAction;
|
||||
|
@ -33,7 +32,7 @@ import java.util.Set;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient;
|
||||
import static com.dabsquared.giteejenkins.connection.GiteeConnectionProperty.getClient;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
|
@ -43,7 +42,7 @@ public class CommitStatusUpdater {
|
|||
private final static Logger LOGGER = Logger.getLogger(CommitStatusUpdater.class.getName());
|
||||
|
||||
public static void updateCommitStatus(Run<?, ?> build, TaskListener listener, BuildState state, String name) {
|
||||
GitLabClient client = getClient(build);
|
||||
GiteeClient client = getClient(build);
|
||||
if (client == null) {
|
||||
println(listener, "No GitLab connection configured");
|
||||
return;
|
||||
|
@ -52,14 +51,14 @@ public class CommitStatusUpdater {
|
|||
try {
|
||||
final String buildUrl = getBuildUrl(build);
|
||||
|
||||
for (final GitLabBranchBuild gitLabBranchBuild : retrieveGitlabProjectIds(build, build.getEnvironment(listener))) {
|
||||
for (final GiteeBranchBuild GiteeBranchBuild : retrieveGitlabProjectIds(build, build.getEnvironment(listener))) {
|
||||
try {
|
||||
if (existsCommit(client, gitLabBranchBuild.getProjectId(), gitLabBranchBuild.getRevisionHash())) {
|
||||
client.changeBuildStatus(gitLabBranchBuild.getProjectId(), gitLabBranchBuild.getRevisionHash(), state, getBuildBranch(build), name, buildUrl, state.name());
|
||||
if (existsCommit(client, GiteeBranchBuild.getProjectId(), GiteeBranchBuild.getRevisionHash())) {
|
||||
client.changeBuildStatus(GiteeBranchBuild.getProjectId(), GiteeBranchBuild.getRevisionHash(), state, getBuildBranch(build), name, buildUrl, state.name());
|
||||
}
|
||||
} catch (WebApplicationException | ProcessingException e) {
|
||||
printf(listener, "Failed to update Gitlab commit status for project '%s': %s%n", gitLabBranchBuild.getProjectId(), e.getMessage());
|
||||
LOGGER.log(Level.SEVERE, String.format("Failed to update Gitlab commit status for project '%s'", gitLabBranchBuild.getProjectId()), e);
|
||||
printf(listener, "Failed to update Gitlab commit status for project '%s': %s%n", GiteeBranchBuild.getProjectId(), e.getMessage());
|
||||
LOGGER.log(Level.SEVERE, String.format("Failed to update Gitlab commit status for project '%s'", GiteeBranchBuild.getProjectId()), e);
|
||||
}
|
||||
}
|
||||
} catch (IOException | InterruptedException | IllegalStateException e) {
|
||||
|
@ -83,7 +82,7 @@ public class CommitStatusUpdater {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean existsCommit(GitLabClient client, String gitlabProjectId, String commitHash) {
|
||||
private static boolean existsCommit(GiteeClient client, String gitlabProjectId, String commitHash) {
|
||||
try {
|
||||
client.getCommit(gitlabProjectId, commitHash);
|
||||
return true;
|
||||
|
@ -102,25 +101,25 @@ public class CommitStatusUpdater {
|
|||
return DisplayURLProvider.get().getRunURL(build);
|
||||
}
|
||||
|
||||
private static List<GitLabBranchBuild> retrieveGitlabProjectIds(Run<?, ?> build, EnvVars environment) {
|
||||
LOGGER.log(Level.INFO, "Retrieving gitlab project ids");
|
||||
final List<GitLabBranchBuild> result = new ArrayList<>();
|
||||
private static List<GiteeBranchBuild> retrieveGitlabProjectIds(Run<?, ?> build, EnvVars environment) {
|
||||
LOGGER.log(Level.INFO, "Retrieving gitee project ids");
|
||||
final List<GiteeBranchBuild> result = new ArrayList<>();
|
||||
|
||||
GiteeWebHookCause gitlabCause = build.getCause(GiteeWebHookCause.class);
|
||||
if (gitlabCause != null) {
|
||||
return Collections.singletonList(new GitLabBranchBuild(
|
||||
return Collections.singletonList(new GiteeBranchBuild(
|
||||
gitlabCause.getData().getSourceProjectId().toString(), gitlabCause.getData().getLastCommit()));
|
||||
}
|
||||
|
||||
// Check upstream causes for GiteeWebHookCause
|
||||
List<GitLabBranchBuild> builds = findBuildsFromUpstreamCauses(build.getCauses());
|
||||
List<GiteeBranchBuild> builds = findBuildsFromUpstreamCauses(build.getCauses());
|
||||
if (!builds.isEmpty()) {
|
||||
return builds;
|
||||
}
|
||||
|
||||
final GitLabClient gitLabClient = getClient(build);
|
||||
if (gitLabClient == null) {
|
||||
LOGGER.log(Level.WARNING, "No gitlab client found.");
|
||||
final GiteeClient giteeClient = getClient(build);
|
||||
if (giteeClient == null) {
|
||||
LOGGER.log(Level.WARNING, "No gitee client found.");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -131,7 +130,7 @@ public class CommitStatusUpdater {
|
|||
}
|
||||
|
||||
if (buildDatas.size() == 1) {
|
||||
addGitLabBranchBuild(result, getBuildRevision(build), buildDatas.get(0).getRemoteUrls(), environment, gitLabClient);
|
||||
addGiteeBranchBuild(result, getBuildRevision(build), buildDatas.get(0).getRemoteUrls(), environment, giteeClient);
|
||||
} else {
|
||||
final SCMRevisionAction scmRevisionAction = build.getAction(SCMRevisionAction.class);
|
||||
|
||||
|
@ -150,7 +149,7 @@ public class CommitStatusUpdater {
|
|||
for (final BuildData buildData : buildDatas) {
|
||||
for (final Entry<String, Build> buildByBranchName : buildData.getBuildsByBranchName().entrySet()) {
|
||||
if (buildByBranchName.getValue().getSHA1().equals(ObjectId.fromString(scmRevisionHash))) {
|
||||
addGitLabBranchBuild(result, scmRevisionHash, buildData.getRemoteUrls(), environment, gitLabClient);
|
||||
addGiteeBranchBuild(result, scmRevisionHash, buildData.getRemoteUrls(), environment, giteeClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,23 +177,23 @@ public class CommitStatusUpdater {
|
|||
return action.getLastBuild(lastBuiltRevision.getSha1()).getMarked().getSha1String();
|
||||
}
|
||||
|
||||
private static void addGitLabBranchBuild(List<GitLabBranchBuild> result, String scmRevisionHash,
|
||||
Set<String> remoteUrls, EnvVars environment, GitLabClient gitLabClient) {
|
||||
private static void addGiteeBranchBuild(List<GiteeBranchBuild> result, String scmRevisionHash,
|
||||
Set<String> remoteUrls, EnvVars environment, GiteeClient giteeClient) {
|
||||
for (String remoteUrl : remoteUrls) {
|
||||
try {
|
||||
LOGGER.log(Level.INFO, "Retrieving the gitlab project id from remote url {0}", remoteUrl);
|
||||
final String projectNameWithNameSpace = ProjectIdUtil.retrieveProjectId(gitLabClient, environment.expand(remoteUrl));
|
||||
LOGGER.log(Level.INFO, "Retrieving the gitee project id from remote url {0}", remoteUrl);
|
||||
final String projectNameWithNameSpace = ProjectIdUtil.retrieveProjectId(giteeClient, environment.expand(remoteUrl));
|
||||
if (StringUtils.isNotBlank(projectNameWithNameSpace)) {
|
||||
String projectId = projectNameWithNameSpace;
|
||||
if (projectNameWithNameSpace.contains(".")) {
|
||||
try {
|
||||
projectId = gitLabClient.getProject(projectNameWithNameSpace).getId().toString();
|
||||
projectId = giteeClient.getProject(projectNameWithNameSpace).getId().toString();
|
||||
} catch (WebApplicationException | ProcessingException e) {
|
||||
LOGGER.log(Level.SEVERE, String.format("Failed to retrieve projectId for project '%s'",
|
||||
projectNameWithNameSpace), e);
|
||||
}
|
||||
}
|
||||
result.add(new GitLabBranchBuild(projectId, scmRevisionHash));
|
||||
result.add(new GiteeBranchBuild(projectId, scmRevisionHash));
|
||||
}
|
||||
} catch (ProjectIdUtil.ProjectIdResolutionException e) {
|
||||
LOGGER.log(Level.WARNING, "Did not match project id in remote url.");
|
||||
|
@ -202,7 +201,7 @@ public class CommitStatusUpdater {
|
|||
}
|
||||
}
|
||||
|
||||
private static List<GitLabBranchBuild> findBuildsFromUpstreamCauses(List<Cause> causes) {
|
||||
private static List<GiteeBranchBuild> findBuildsFromUpstreamCauses(List<Cause> causes) {
|
||||
for (Cause cause : causes) {
|
||||
if (cause instanceof UpstreamCause) {
|
||||
List<Cause> upCauses = ((UpstreamCause) cause).getUpstreamCauses(); // Non null, returns empty list when none are set
|
||||
|
@ -210,11 +209,11 @@ public class CommitStatusUpdater {
|
|||
if (upCause instanceof GiteeWebHookCause) {
|
||||
GiteeWebHookCause gitlabCause = (GiteeWebHookCause) upCause;
|
||||
return Collections.singletonList(
|
||||
new GitLabBranchBuild(gitlabCause.getData().getSourceProjectId().toString(),
|
||||
new GiteeBranchBuild(gitlabCause.getData().getSourceProjectId().toString(),
|
||||
gitlabCause.getData().getLastCommit()));
|
||||
}
|
||||
}
|
||||
List<GitLabBranchBuild> builds = findBuildsFromUpstreamCauses(upCauses);
|
||||
List<GiteeBranchBuild> builds = findBuildsFromUpstreamCauses(upCauses);
|
||||
if (!builds.isEmpty()) {
|
||||
return builds;
|
||||
}
|
||||
|
@ -223,11 +222,11 @@ public class CommitStatusUpdater {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static class GitLabBranchBuild {
|
||||
public static class GiteeBranchBuild {
|
||||
private final String projectId;
|
||||
private final String revisionHash;
|
||||
|
||||
public GitLabBranchBuild(final String projectId, final String revisionHash) {
|
||||
public GiteeBranchBuild(final String projectId, final String revisionHash) {
|
||||
this.projectId = projectId;
|
||||
this.revisionHash = revisionHash;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.dabsquared.gitlabjenkins.util;
|
||||
package com.dabsquared.giteejenkins.util;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue