Jenkins : Git Client Plugin

Plugin Information

View Git client on the plugin site for more information.

Older versions of this plugin may not be safe to use. Please review the following warnings before using an older version:

Official Documentation

'Shared library plugin for other Git related Jenkins plugins.


Plugin provides a builder-style factory to retrieve a GitClient:

GitClient git = Git.with(listener, environment)

Using "jgit" will force use of JGit implementation.


GIT_ASKPASS and permissions

The Git Client plugins uses GIT_ASKPASS and creates a temporary script to execute when git prompts for credentials. This approach requires that the user running Jenkins or the Agent has the sufficient permissions (read/write/execute) on the temp folder.

This has always been true for SSH Authentication. It however has not always been the case for HTTP/s authentication. Since version 2.0.0, the Git Client plugin now uses GIT_ASKPASS for Username/Password credentials too. See the detailed explanation in this commit. If you are upgrading to this version ensure that the temporary folder permissions are configured accordingly.

Insufficient permissions on the temp folder would make git commands fail with a stacktrace similar to the following:

hudson.plugins.git.GitException: Command "/usr/local/bin/git fetch --tags --progress +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stderr: fatal: cannot exec '/tmp/': Permission denied
fatal: could not read Username for '': No such device or address

Note: If security on the default temp folder is a concern, note that you can change the location of the temp folder in Jenkins via the system property ``as explained in here. This would need to be done on the Jenkins master and the Agents.

Change Log - Moved to GitHub

2.8.0 (June 16, 2019)

  • (info)   Require Java 8
  • (info)   Require Jenkins 2.121 or later
  • (info) Use JGit 4.5.7 (rather than JGit 4.5.5) 

3.0.0-beta9 (April 24, 2019)

  • (info)   Require Java 8
  • (info)   Require Jenkins 2.60
  • (info)   Use JGit 5.3.0 instead of JGit 4.5.4 (many bug fixes, more consistent with command line git, includes git protocol 2 support)
  • (info)   Add optional submodule delete when cleaning (JENKINS-26660)
  • (info)   Add optional parallel submodule update support (JENKINS-44720)
  • (info)   Add optional shallow submodule update support (JENKINS-21248)
  • (info)   Always log the timeout for a CliGit command (JENKINS-52891)
  • (info)   Add test utility for use by git plugin test automation
  • (error)   Fix openPackedFromSelfOrAlternate stack overflow in JGit (JENKINS-46344)
  • (error)   Use distinctive file name prefix for temporary files (JENKINS-48258)
  • (error)   Fix clean before checkout with specific JGit directory and file name patterns (JENKINS-43198)
  • (error)   Use ssh username from git URL instead of passed username (OpenSSH 7.7 fix) (JENKINS-50573, JENKINS-52721JENKINS-52678)
  • (error)   Avoid 'text file busy' random ssh clone failures (JENKINS-48258)
  • (error)   Use NTLM as Windows fallback authentication in JGit (JGit fix) (JENKINS-37934)
  • (error)   Allow shell special characters in passwords (JENKINS-47514)
  • (error)   Prevent 'Could not initialize class ... MasterComputer' in withRepository() remote call (JENKINS-49402JENKINS-50019JENKINS-53279)

2.7.7 (April 11, 2019)

  • (info)   Use JGit 4.5.5 (rather than JGit 4.5.4)
  • (info)   Automated test extension to better support git plugin test automation

2.7.6 (January 10, 2019)

  • (error)   Part 2 - Adapt to CLI git 2.20 tag update behavior change (JENKINS-55284)

2.7.5 (December 22, 2018)

  • (error)   Adapt to CLI git 2.20 tag update behavior change (JENKINS-55284)

2.7.4 (November 16, 2018)

2.7.3 (July 24, 2018)

2.7.2 (May 12, 2018)

  • (error)   Adapt to OpenSSH 7.7 behavior change for command line arguments, as seen in Windows git 2.17.0, Debian Buster, and OpenBSD 6.3 (JENKINS-50573)

2.7.1 (January 25, 2018)

2.7.0 (December 18, 2017)

  • (error)   Add GitClient.getTags() to fix git rev-parse related checkout performance regression (JENKINS-45447 and JENKINS-47169)
  • (error)   Fix submodule cloning for repository URLs that end with '.url' (JENKINS-46054)
  • (error)   Make GitClient.getRemoteReferences() return empty map from both implementations when remote references are not found (JENKINS-30589)
  • (info)   Use JGit 4.5.4 (rather than JGit 4.5.3) (fix some cases of incorrect NFS file locking)
  • (info)   Improve GitClient.isCommitInRepo() performance with the "--no-walk" argument

2.6.0 (October 27, 2017)

  • (error)   Fix unit test failures on freshly installed systems (JENKINS-47373)
  • (error)   Fix ArrayBoundsException when repository includes commit with embedded control character(JENKINS-45894, JENKINS-47196)
  • (info)   Use env vars to prevent command line credential (CLI git 2.3+) prompts which block the plugin (JENKINS-35959, JENKINS-25878)
  • (info)   Add API to support LFS credentials separate from repository credentials (JENKINS-47531)
  • (info)   Report the path to a reference repository if reference repository is configured and used (JENKINS-46737)
  • (info)   Use JGit 4.5.3 (rather than JGit 4.5.2)
  • (info)   Use apache http client plugin and jsch as bundled with Jenkins

2.5.0 (July 27, 2017)

  • (error)   Honor credential path exclusion (JENKINS-43022)
  • (error)   Fix a submodule case of "no revision to build" (JENKINS-45729)
  • (info)   Add a RECURSIVE_THEIRS merge strategy
  • (info)   Detect setsid command in /usr/local/bin (MacOS) (JENKINS-20879)
  • (info)   Allow boolean options to be toggled rather than just set (JENKINS-45771)

2.4.6 (May 24, 2017)

2.4.5 (April 29, 2017)

  • (error)   Fix Windows regression when using passphrase protected private keys with a workspace name containing a space (JENKINS-43931)

2.4.4 (April 27, 2017)

2.4.2 (April 20, 2017)

  • (info)   Support passphrase protected private keys even when Jenkins is attached to a controlling terminal (docker with "-it" argument, or "mvn hpi:run") (JENKINS-20879, JENKINS-25194)
  • (info)   Require credentials plugin 2.1.13 for credentials tracking API support
  • (info)   Use JGit 4.5.2 (bug fix)
  • (info)   Add Italian language translation

2.4.1 (March 30, 2017)

2.4.0 (March 24, 2017)

  • (info)   Add API to determine default remote branch (JENKINS-40834)
  • (info)   Use JGit 4.5.1 (bug fixes)

2.3.0 (February 28, 2017)

2.2.1 (January 16, 2017)

2.2.0 (January 2, 2017)

2.1.0 (November 3, 2016)

2.0.0 (September 10, 2016)

  • (info)   Require Java 7 (Jenkins 1.625 or newer) - try with resources and other code simplifications
  • (info)   Use JGit 4.4.1
  • (info)   Use Apache httpclient 4.5.2

1.21.0 (August 20, 2016)

1.19.7 (July 15, 2016)

2.0.0-beta1 (June 14, 2016)

  • (info)   Require Java 7 (Jenkins 1.625 or newer) - try with resources and other code simplifications
  • (info)   Use JGit 4.3.1 (though may be affected by JGit bug 496262)
  • (info)   Use Apache httpclient 4.5.2

1.20.0-beta3 (March 10, 2016)

1.19.6 (March 6, 2016)

  • (error)   Guard rev-parse calls from surprise blank lines (JENKINS-20991)
  • (error)   Reduce memory use generating changelog (JENKINS-31326 partial fix, also needs new git plugin)

1.19.5 (February 17, 2016) 824604b

  • (info)   Warn if JGit fetch attempted with shallow clone options, don't throw exception

1.19.4 (February 9, 2016)

  • (error)   Fix one case of passphrase protected ssh clone (JENKINS-32834)

1.19.3 (February 6, 2016)

1.19.2 (January 9, 2016)

  • (error)   Improve performance of calls to git rev-parse (JENKINS-32258)

1.20.0-beta1 (November 4, 2015)

  • (info)   Support submodule authentication (JENKINS-20941) - requires git plugin 2.5.0-beta1

1.19.1 (December 26, 2015)

1.19.0 (August 20, 2015)

1.18.0 (July 18, 2015)

  • (info)   Update minimum Jenkins version from 1.509 to 1.532.2
  • (info)   Update JGit to 3.7.1
  • (info)   Add squash as merge option (JENKINS-28833)
  • (error)   Allow Linux ssh keys with passphrase (JENKINS-20638, JENKINS-20879, JENKINS-27998)
  • (error)   Implement prune for JGit repositories (JENKINS-26197)
  • (error)   Improve checkout failure message (JENKINS-26748)
  • (error)   Use ISO-8601 date format in changelog (JENKINS-27097)
  • (error)   Find ssh.exe on Windows even if git is in cmd directory (JENKINS-28943)
  • (error)   Guard against null pointer exceptions in several API calls
  • (info)   Update other dependencies (httpclient 4.4.1, ssh-credentials 1.11, etc.)

1.17.1 (May 8, 2015)

1.17.0 (April 25, 2015)

  • (info)   Update minimum Jenkins version from 1.509 to 1.532.2
  • (info)   Update JGit to 3.7.0
  • (error)   Implement prune for JGit repositories (JENKINS-26197)
  • (error)   Use ISO-8601 date format in changelog (JENKINS-27097)
  • (error)   Improve checkout failure message (JENKINS-26748)
  • (error)   Guard against null pointer exceptions in several API calls
  • (info)   Update other dependencies (httpclient 4.4.1, ssh-credentials 1.11, etc.)

1.16.1 (February 6, 2015)

  • (info)   Allow API access to all merge modes, including fast forward, and no fast forward (JENKINS-12402)
  • (info)   Allow clone with multiple refspecs (JENKINS-26417)
  • (info)   Improve javadoc, including fixes for Java 8 javadoc

1.15.0 (January 6, 2015)

  • (info)   Update from JGit 3.6.0 to JGit 3.6.1
  • (error)   Guard web pages with "jelly escape"

1.14.1 (December 27, 2014)

  • (error)   Only use "-c core.askpass=true" if command line git is newer than 1.7.9 (don't break really old git versions unnecessarily)

1.14.0 (December 25, 2014)

1.13.0 (December 18, 2014)

  • (error)   Update from JGit 3.5.2 to JGit 3.5.3 (CVE-2014-9390)
  • (error)   Remove .git/index.lock on command line git crash (JENKINS-25353)
  • (info)   Update a few dependencies, resolve a few findbugs warnings

1.12.0 (November 25, 2014)

  • (info)   Update from JGit 3.5.1 to JGit 3.5.2
  • (info)   Revision object now provides equals() and hashCode() (JENKINS-25639)
  • (info)   Update commons-codec to 1.10

1.11.1 (November 7, 2014)

  • (info)   Allow reference repositories with JGit - faster clone/fetch when commits are already in the reference repo (JENKINS-25387)
  • (info)   Add getBranchesContaining() to GitClient API - report branches containing a specific SHA1
  • (info)   Add getRemoteReferences() to GitClient API - list remote references without a repository
  • (info)   Allow PushCommand to push tags
  • (error)   Fix JGit fetch() to match CliGit behavior - delete local changes (JENKINS-25444)
  • (info)   Various test additions and improvements

1.11.0 (October 18, 2014)

  • (info)   Update from JGit 3.4.1 to JGit 3.5.1
  • (info)   Bundle jgit http server in git-client-plugin for easier version maintenance (JENKINS-21756)
  • (info)   Various test additions and improvements

1.10.2 (September 12, 2014)

  • (info)   Support authenticating proxies (JENKINS-24112)
  • (info)   Add API entry point for getRemoteTagNames
  • (info)   Warn Windows users if TEMP or TMP contains embedded space (JENKINS-22706)
  • (error)   Fix tag comparison (when refs/tags/tag_name is the branch to build) so tag based builds don't build at every poll (JENKINS-23299)

1.10.1 (July 30, 2014)

  • (info)   Timeout on checkout can be adjusted (JENKINS-22400)
  • (info)   Add API entry point to list first parent of revision list

1.10.0 (July 22, 2014)

  • (info)   Allow "Branches to build" to use refs/heads/ to specify branch precisely (JENKINS-23884, JENKINS-23266)
  • (info)   Add API entry points to manage refs through GitClient

1.9.2 (July 16, 2014)

  • (info)   Upgrade JGit to 3.4.1, httpclient 4.3.4, ssh-credentials 1.7.1
  • (info)   Simplify the pom
  • (error)   Improve ssh.exe location guessing on Windows (JENKINS-21806)
  • (error)   Reset tracked file local modifications on JGit checkout (JENKINS-23424)

1.9.1 (May 21, 2014)

  • (info)   Simplify the pom
  • (error)   Support polling behind an http proxy (JENKINS-22999)
  • (error)   Remove temp directory after authenticated fast remote poll (JENKINS-23017)

1.9.0 (May 8, 2014)

  • (info)   Allow timeout setting for submodule updates (JENKINS-22400)
  • (info)   Upgrade JGit to 3.4.0
  • (info)   Several test related improvements (Windows "busy file" test failures silenced on JDK 8, etc.)
  • (error)   Correctly display first revision when using JGit (JENKINS-22343)

1.8.1 (May 3, 2014)

  • (info)   Allow switch branch of a submodule before update (for later use in git plugin)
  • (info)   Upgrade JGit to 3.3.2
  • (info)   Several test related improvements (JaCoCo 0.7.0, Windows "busy file" test failures silenced, etc.)
  • (info)   Log executed git commands for easier diagnosis
  • (error)   Only use progress argument on git versions which support it
  • (error)   Warn if git version is too old for credentials support (JENKINS-21887)
  • (error)   Use a new temporary directory for remote polling of authenticated repositories (JENKINS-22039)

1.8.0 (April 3, 2014)

  • (info)   Upgrade JGit from 3.3.0 to 3.3.1
  • (info)   Update remote tracking branch support for submodules if using command line git version 1.8.2 or newer

1.7.0 (March 27, 2014)

  • (error)   Fix symlink behavior in CliGit checkout (JENKINS-22376, JENKINS-21168, and JENKINS-22391)
  • (info)   Add remote tracking branch support for submodules if using command line git version 1.8.2 or newer

1.6.6 (March 25, 2014)

  • (info)   Switch CheckoutCommand from abstract class to interface (sparse checkout support)

1.6.5 (March 22, 2014)

  • (info)   Add sparse checkout support (requires git-plugin 2.0.5, requires git 1.8.2)
  • (info)   Upgrade JGit from 3.2.0 to 3.3.0
  • (info)   Enable push from JGit
  • (info)   QA improvements (more tests)

1.6.4 (March 6, 2014)

  • (info)   Add NTLM authentication (for Team Foundation Server git implementation)
  • (info)   Support branch change detection in branches using namespaces (e.g. develop1/master)
  • (info)   Replace obsolete Apache HttpClient with Apache HttpComponents
  • (warning)   Require at least Jenkins 1.509 so that authentication can be tested
  • (info)   QA improvements (more tests, findbugs warnings fixes, etc.)

1.6.3 (February 20, 2014)

  • (error)   Set remote URL during clone (implemented as init + fetch) to mimic an actual clone
  • (info)   CLI impl getRemoteUrl support empty git directory (align to JGit impl)
  • (info)   QA improvements

1.6.2 (February 04, 2014)

1.6.1 (January 10, 2014)

  • (error)   Warn when credentials.helper can be removed form config but don't fail the command
  • (error)   Fix git-credentials-store syntax(JENKINS-21016)
  • (error)   Fix a file leak when JGit is used(JENKINS-19994)
  • (info)   Test coverage improvement (thanks to Mark Waite)
  • (info)   Throw GitLockFailedException on lock failure (to allow retry)
  • (info)   Printing error message on SSLException to help diagnose ssl problems

1.6 (December 18, 2013)

  • (info)   Method to push to URL (not implemented yet by JGit)
  • (info)   Method to add URL for remote (i.e. git config --add bar)

1.5 (December 14, 2013)

1.4.6 (October 30, 2013)

  • (error)   Fix ssh private key support (using GIT_SSH) (issue #20223)
  • (error)   Append .git extension to repository URL on 404 (issue #20189)
  • (error)   Fix http proxy support (issue #20326)
  • (error)   Set a time-out running git commands (org.jenkinsci.plugins.gitclient.Git.timeOut, defaults to 10 minutes) (issue #11286)

1.4.5 (October 24, 2013)

1.4.4 (October 22, 2013)

  • (error)   Make JGit checkout compliant with CliGit
  • (error)   Support for http proxy (issue #20218)

1.4.3 (October 17, 2013)

  • (error)   Fix changelog generation on windows (JENKINS-18995)
  • (error)   Add support for .netrc as credential source for http(s) transport (backward compatibility)

1.4.2 (October 13, 2013)

  • (error)   Fix username/password support (JENKINS-19974, JENKINS-19995)
  • (error)   username/password can also be set in repository URL (backward compatibility issue)

1.4.0 (October 10, 2013)

  • (info)   JGit upgrade
  • (info)   Add support for username/password credentials

1.3.0 (September 21, 2013)

  • (info)   Add support for --shared option
  • (info)   JGit upgrade
  • (info)   Align JGit behavior for checkout to git-cli one (JENKINS-18988)
  • (error)   Bug in JGit implemenation (JENKINS-19108)

1.2.0 (September 16, 2013)

  • (info)   Support for SSH Credentials within Git CLI implementation using ssh-agent plugin

1.1.2 (August 07, 2013)

  • (info)   Integration with updates to Credentials and SSH Credentials plugins
  • (error)   Bug in JGit implementation of git-describe

1.1.1 (July 25, 2013)

  • (error)   Misnamed resource

1.1 (July 24th, 2013)

  • (info)   JGit implementation is feature complete
  • (info)   GitClient interface is now remotable (can be used safely as an argument/return value to remote call)

1.0.7 (June 6th, 2013)

  • (error)   Fixed exception when trying to use Git plugin immediately after installing without restart.

1.0.6 (May 11, 2013)

  • (info)   Resurrect the checkoutBranch method
  • (info)   Support multi-line commit messages for tags

1.0.5 (March 21, 2013)

  • (warning)   Reverted default implementation to use git-cli, after many regressions reported by users. org.jenkinsci.plugins.gitclient.Git.useCLI=false can be used to test JGit support.

1.0.4 (March 12, 2013)

  • (error)   Consider first installation as "Default" if not explicitly set (JENKINS-17013).
  • (info)   Implement clean, revParse, deleteTag, getTagMessage, hasGitRepo, isCommitInRepo, addSubmodule in pure JGit
  • (info)   Introduce new method to commit with committer/author
  • (warning)   Use JGit implementation in GitAPI for all supported methods, until org.jenkinsci.plugins.gitclient.Git.useCLI is set

1.0.3 (February 28, 2013)

  • (error)   Delete workspace content, not workspace directory, before cloning (JENKINS-16873)
  • (error)   Warn and ignore parameter, but don't break if reference is invalid (JENKINS-16911)
  • (error)   Clarify API usage with more explicit parameter name (JENKINS-16914)
  • (error)   Lock on repository files (issue #12188)
  • (info)   Implement push in pure JGit

1.0.2 (February 19, 2013)

  • initial design, with GitClient factory