diff --git a/pom.xml b/pom.xml index cac7f27..fff463a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.englishtown stash-hook-mirror - 2.4.0-SNAPSHOT + 2.4.1-SNAPSHOT Englishtown diff --git a/src/main/java/com/englishtown/bitbucket/hook/MirrorBucketProcessor.java b/src/main/java/com/englishtown/bitbucket/hook/MirrorBucketProcessor.java index a48220a..cc15a1a 100644 --- a/src/main/java/com/englishtown/bitbucket/hook/MirrorBucketProcessor.java +++ b/src/main/java/com/englishtown/bitbucket/hook/MirrorBucketProcessor.java @@ -9,6 +9,7 @@ import com.atlassian.bitbucket.scm.Command; import com.atlassian.bitbucket.scm.ScmCommandBuilder; import com.atlassian.bitbucket.scm.ScmService; import com.atlassian.bitbucket.scm.git.command.GitCommandExitHandler; +import com.atlassian.bitbucket.scm.git.command.GitScmCommandBuilder; import com.atlassian.bitbucket.server.ApplicationPropertiesService; import com.atlassian.bitbucket.user.SecurityService; import com.google.common.base.Strings; @@ -88,13 +89,22 @@ public class MirrorBucketProcessor implements BucketProcessor { // Call push command with the prune flag and refspecs for heads and tags // Do not use the mirror flag as pull-request refs are included - ScmCommandBuilder builder = scmService.createBuilder(repository) + ScmCommandBuilder obj = scmService.createBuilder(repository) .command("push") .argument("--prune") // this deletes locally deleted branches .argument(authenticatedUrl) .argument("--force"); - // Use an atomic transaction to have a consistent state + // Use GitBuilder to allow git settings to be passed + GitScmCommandBuilder builder = (GitScmCommandBuilder) obj; + + if (!settings.verifySsl) { + builder.withConfiguration("http.sslVerify", false); + } + + + + // Use an atomicw transaction to have a consistent state if (settings.atomic) { builder.argument("--atomic"); } @@ -116,6 +126,8 @@ public class MirrorBucketProcessor implements BucketProcessor { builder.argument("+refs/notes/*:refs/notes/*"); } + + PasswordHandler passwordHandler = new PasswordHandler(settings.password, new GitCommandExitHandler(i18nService, repository)); diff --git a/src/main/java/com/englishtown/bitbucket/hook/MirrorRepositoryHook.java b/src/main/java/com/englishtown/bitbucket/hook/MirrorRepositoryHook.java index 643904d..f41fa2f 100644 --- a/src/main/java/com/englishtown/bitbucket/hook/MirrorRepositoryHook.java +++ b/src/main/java/com/englishtown/bitbucket/hook/MirrorRepositoryHook.java @@ -35,6 +35,7 @@ public class MirrorRepositoryHook implements PostRepositoryHook mirrorSettings = getMirrorSettings(settings, false, false, false); + List mirrorSettings = getMirrorSettings(settings, false, false, false, false); for (MirrorSettings ms : mirrorSettings) { if (!validate(ms, errors)) { ok = false; @@ -144,10 +145,10 @@ public class MirrorRepositoryHook implements PostRepositoryHook getMirrorSettings(Settings settings) { - return getMirrorSettings(settings, true, true, true); + return getMirrorSettings(settings, true, true, true, true); } - private List getMirrorSettings(Settings settings, boolean defTags, boolean defNotes, boolean defAtomic) { + private List getMirrorSettings(Settings settings, boolean defTags, boolean defNotes, boolean defAtomic, boolean defVerifySsl) { Map allSettings = settings.asMap(); int count = 0; @@ -164,6 +165,7 @@ public class MirrorRepositoryHook implements PostRepositoryHook