Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
compile group: 'org.rundeck', name: 'rundeck-core', version: '2.11.4'
compile 'org.slf4j:slf4j-api:1.7.30'

pluginLibs( 'org.eclipse.jgit:org.eclipse.jgit:4.4.0.201606070830-r') {
pluginLibs( 'org.eclipse.jgit:org.eclipse.jgit:5.6.0.201912101111-r') {
exclude module: 'slf4j-api'
exclude module: 'jsch'
exclude module: 'commons-logging'
Expand Down
15 changes: 13 additions & 2 deletions src/main/groovy/com/rundeck/plugin/GitManager.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import org.eclipse.jgit.api.Git
import org.eclipse.jgit.api.PullResult
import org.eclipse.jgit.api.TransportCommand
import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.lib.SubmoduleConfig.FetchRecurseSubmodulesMode
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
import org.eclipse.jgit.transport.RemoteRefUpdate
import org.eclipse.jgit.transport.URIish
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider
import org.eclipse.jgit.util.FileUtils
import org.eclipse.jgit.api.SubmoduleUpdateCommand

import java.nio.file.Files
import java.nio.file.Path
Expand Down Expand Up @@ -83,6 +85,7 @@ class GitManager {
} else {
performClone(base)
}
repo.close()
}


Expand All @@ -100,7 +103,6 @@ class GitManager {
setURI(this.gitURL).
setCloneSubmodules(true)


try {
setupTransportAuthentication(sshConfig, cloneCommand, this.gitURL)
git = cloneCommand.call()
Expand All @@ -117,15 +119,21 @@ class GitManager {

def pullCommand = git.pull()
.setRebase(true)
.setRecurseSubmodules(FetchRecurseSubmodulesMode.YES)

try {
setupTransportAuthentication(sshConfig, pullCommand, this.gitURL)
PullResult result = pullCommand.call()

if (!result.isSuccessful()) {
logger.info("Pull is not successful.")
} else {
logger.debug("Pull is not successful.")
}

def submoduleUpdateCommand = new SubmoduleUpdateCommand(git.getRepository())
submoduleUpdateCommand.call()

} catch (Exception e) {
e.printStackTrace()
logger.debug("Failed pulling the repository from ${this.gitURL}: ${e.message}", e)
Expand Down Expand Up @@ -173,7 +181,10 @@ class GitManager {
}

PullResult gitPull(Git git1 = null) {
def pullCommand = (git1 ?: git).pull().setRemote(REMOTE_NAME).setRemoteBranchName(branch)
def pullCommand = (git1 ?: git).pull()
.setRemote(REMOTE_NAME)
.setRemoteBranchName(branch)
.setRecurseSubmodules(FetchRecurseSubmodulesMode.YES)
setupTransportAuthentication(sshConfig, pullCommand)
pullCommand.call()
}
Expand Down