Skip to content

Commit

Permalink
[JENKINS-53697] git validate with requiredPush always return 428 (#1815)
Browse files Browse the repository at this point in the history
* fix

* fix ci
  • Loading branch information
runzexia authored and olamy committed Sep 29, 2018
1 parent 9c9d737 commit 2cedce9
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -29,6 +29,7 @@
import jenkins.model.Jenkins;
import jenkins.plugins.git.AbstractGitSCMSource;
import jenkins.plugins.git.GitSCMFileSystem;
import jenkins.plugins.git.GitSCMSource;
import jenkins.scm.api.SCMSourceOwner;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
Expand Down Expand Up @@ -209,8 +210,8 @@ public HttpResponse validateAndCreate(@JsonBody JSONObject request) {
final AbstractGitSCMSource scmSource;

if (request.has("repositoryUrl")) {
scmSource = null;
repositoryUrl = request.getString("repositoryUrl");
scmSource = new GitSCMSource(repositoryUrl);
} else {
try {
String fullName = request.getJSONObject("pipeline").getString("fullName");
Expand Down Expand Up @@ -273,9 +274,11 @@ public HttpResponse validateAndCreate(@JsonBody JSONObject request) {
}

try {

if (requirePush) {
String branch = request.getString("branch");
if (repositoryUrl != null){
((GitSCMSource) scmSource).setCredentialsId(credentialId);
}
new GitBareRepoReadSaveRequest(scmSource, branch, null, branch, null, null)
.invokeOnScm(new GitSCMFileSystem.FSFunction<Void>() {
@Override
Expand Down

0 comments on commit 2cedce9

Please sign in to comment.