Fix wrong URL being send to Gitlab

Also a fix for MergeRequests containing source branch instead of commit
hash
This commit is contained in:
Tom 2015-10-30 20:03:26 +01:00
parent edd0e7f586
commit 7b8a85c044
3 changed files with 8 additions and 9 deletions

View File

@ -65,9 +65,8 @@ public class GitLabMergeRequest extends GitLabRequest {
public GitlabCommitStatus createCommitStatus(GitlabAPI api, String status, String targetUrl) {
try {
GitlabMergeRequest mergeRequest = api.getMergeRequest(sourceProject, objectAttributes.getId());
if(objectAttributes.lastCommit!=null) {
return api.createCommitStatus(sourceProject, objectAttributes.getLastCommit().getId(), status, mergeRequest.getSourceBranch(), "Jenkins", targetUrl, null);
return api.createCommitStatus(sourceProject, objectAttributes.getLastCommit().getId(), status, objectAttributes.getLastCommit().getId(), "Jenkins", targetUrl, null);
}
} catch (IOException e) {
e.printStackTrace();

View File

@ -39,7 +39,7 @@ public class GitLabPushRequest extends GitLabRequest {
public GitlabCommitStatus createCommitStatus(GitlabAPI api, String status, String targetUrl) {
try {
if(getLastCommit()!=null) {
return api.createCommitStatus(sourceProject, getLastCommit().getId(), status, checkout_sha, "Jenkins", targetUrl, null);
return api.createCommitStatus(sourceProject, checkout_sha, status, checkout_sha, "Jenkins", targetUrl, null);
}
} catch (IOException e) {
e.printStackTrace();

View File

@ -207,7 +207,7 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
}
if(addCiMessage) {
req.createCommitStatus(getDescriptor().getGitlab().instance(), "pending", getDescriptor().gitlabHostUrl);
req.createCommitStatus(getDescriptor().getGitlab().instance(), "pending", Jenkins.getInstance().getRootUrl() + job.getUrl());
}
}
@ -311,7 +311,7 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
}
if(addCiMessage) {
req.createCommitStatus(getDescriptor().getGitlab().instance(), "pending", getDescriptor().gitlabHostUrl);
req.createCommitStatus(getDescriptor().getGitlab().instance(), "pending", Jenkins.getInstance().getRootUrl() + job.getUrl());
}
}
@ -411,7 +411,7 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
private void onCompletedPushRequest(Run run, GitLabPushCause cause) {
if(addCiMessage) {
cause.getPushRequest().createCommitStatus(this.getDescriptor().getGitlab().instance(), run.getResult()==Result.SUCCESS?"success":"failure", this.getDescriptor().gitlabHostUrl);
cause.getPushRequest().createCommitStatus(this.getDescriptor().getGitlab().instance(), run.getResult()==Result.SUCCESS?"success":"failure", Jenkins.getInstance().getRootUrl() + run.getUrl());
}
}
@ -452,7 +452,7 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
}
if(addCiMessage) {
cause.getMergeRequest().createCommitStatus(this.getDescriptor().getGitlab().instance(), run.getResult()==Result.SUCCESS?"success":"failure", this.getDescriptor().gitlabHostUrl);
cause.getMergeRequest().createCommitStatus(this.getDescriptor().getGitlab().instance(), run.getResult()==Result.SUCCESS?"success":"failure", Jenkins.getInstance().getRootUrl() + run.getUrl());
}
}
@ -472,13 +472,13 @@ public class GitLabPushTrigger extends Trigger<Job<?, ?>> {
private void onStartedPushRequest(Run run, GitLabPushCause cause) {
if(addCiMessage) {
cause.getPushRequest().createCommitStatus(this.getDescriptor().getGitlab().instance(), "running", this.getDescriptor().gitlabHostUrl);
cause.getPushRequest().createCommitStatus(this.getDescriptor().getGitlab().instance(), "running", Jenkins.getInstance().getRootUrl() + run.getUrl());
}
}
private void onStartedMergeRequest(Run run, GitLabMergeCause cause) {
if(addCiMessage) {
cause.getMergeRequest().createCommitStatus(this.getDescriptor().getGitlab().instance(), "running", this.getDescriptor().gitlabHostUrl);
cause.getMergeRequest().createCommitStatus(this.getDescriptor().getGitlab().instance(), "running", Jenkins.getInstance().getRootUrl() + run.getUrl());
}
}