|
1 | | -# Git SCM plugin |
| 1 | +# Git plugin |
2 | 2 |
|
3 | | -Git software configuration management for Jenkins |
| 3 | +[](https://ci.jenkins.io/job/Plugins/job/git-plugin/job/master/) |
| 4 | +[](https://github.com/jenkinsci/git-plugin/graphs/contributors) |
| 5 | +[](https://github.com/jenkinsci/git-plugin/releases/latest) |
4 | 6 |
|
5 | | -* see [Jenkins wiki](https://plugins.jenkins.io/git) for feature descriptions |
6 | | -* use [JIRA](https://issues.jenkins-ci.org) to report issues / feature requests |
| 7 | +<img src="https://git-scm.com/images/logos/downloads/Git-Logo-2Color.png" width="303"> |
7 | 8 |
|
8 | | -## Master Branch |
| 9 | +## Introduction |
9 | 10 |
|
10 | | -The master branch is the primary development branch. |
| 11 | +The git plugin provides fundamental git operations for Jenkins projects. |
| 12 | +It can poll, fetch, checkout, branch, list, merge, and tag repositories. |
11 | 13 |
|
12 | | -Branch names using the pattern 'stable-x.y' are development branches |
13 | | -for changes from a base release 'x.y'. For example, stable-3.9 is the |
14 | | -branch used to release fixes based on git plugin 3.9 while master branch |
15 | | -development is preparing for the 4.0.0 release. |
| 14 | +## Contents |
16 | 15 |
|
17 | | -## Contributing to the Plugin |
| 16 | +* [Changelog](#changelog) |
| 17 | +* [Configuration](#configuration) |
| 18 | +* [Extensions](#extensions) |
| 19 | +* [Environment Variables](#environment-variables) |
| 20 | +* [Properties](#properties) |
| 21 | +// * [Pipelines](#pipelines) |
| 22 | +// * [Performance Tuning](#performance-tuning) |
| 23 | +// * [Reference repositories](#reference-repositories) |
| 24 | +* [Combining repositories](#combining-repositories) |
| 25 | +* [Bug Reports](#bug-reports) |
| 26 | +* [Contributing to the Plugin](#contributing-to-the-plugin) |
| 27 | + |
| 28 | +## Changelog |
| 29 | + |
| 30 | +Release notes are recorded in [GitHub](https://github.com/jenkinsci/git-plugin/releases) beginning with git plugin 3.10.1. |
| 31 | +Prior release notes are recorded on the [Jenkins wiki](https://wiki.jenkins.io/display/JENKINS/Git+Plugin#GitPlugin-ChangeLog-MovedtoGitHub). |
| 32 | + |
| 33 | +## Configuration |
| 34 | + |
| 35 | +### Using Credentials |
| 36 | + |
| 37 | +The git plugin supports username / password credentials and private key credentials provided by the [Jenkins credentials plugin](https://plugins.jenkins.io/credentials). |
| 38 | +Select credentials from the job definition drop down menu or enter their identifiers in Pipeline job definitions. |
| 39 | + |
| 40 | +### Push Notifications |
| 41 | + |
| 42 | +### Enabling JGit |
| 43 | + |
| 44 | +See the [git client plugin documentation](https://plugins.jenkins.io/git-client) for instructions to enable JGit. |
| 45 | +JGit becomes available throughout Jenkins once it has been enabled. |
| 46 | + |
| 47 | +## Extensions |
| 48 | + |
| 49 | +### Advanced checkout behaviors |
| 50 | + |
| 51 | +Timeout (in minutes) for checkout operation:: |
| 52 | + Specify a timeout (in minutes) for checkout. |
| 53 | + |
| 54 | +### Advanced clone behaviours |
| 55 | + |
| 56 | +Fetch tags:: |
| 57 | + Deselect this to perform a clone without tags, saving time and disk space when you just want to access what is specified by the refspec. |
| 58 | + |
| 59 | +Honor refspec on initial clone:: |
| 60 | + Perform initial clone using the refspec defined for the repository. |
| 61 | + This can save time, data transfer and disk space when you only need to access the references specified by the refspec. |
| 62 | + |
| 63 | +Shallow clone:: |
| 64 | + Perform shallow clone. |
| 65 | + Git will not download the complete history of the project, saving time and disk space when you just want to access the latest version of a repository. |
| 66 | + |
| 67 | +Shallow clone depth:: |
| 68 | + Set shallow clone depth to the specified numebr of commits. |
| 69 | + Git will only download that many commits from the remote repository, saving time and disk space. |
| 70 | + |
| 71 | +[[clone-reference-repository-path,reference repository path]] |
| 72 | +Path of the reference repo to use during clone:: |
| 73 | + Specify a folder containing a repository that will be used by git as a reference during clone operations. |
| 74 | + This option will be ignored if the folder is not available on the agent. |
| 75 | + |
| 76 | +Timeout (in minutes) for clone and fetch operations:: |
| 77 | + Specify a timeout (in minutes) for clone and fetch operations. |
| 78 | + |
| 79 | +### Advanced sub-modules behaviours |
| 80 | + |
| 81 | +Disable submodules processing:: |
| 82 | + Ignore submodules in the repository. |
| 83 | + |
| 84 | +Recursively update submodules:: |
| 85 | + Retrieve all submodules recursively. |
| 86 | + Without this option, submodules which contain other submodules will ignore the contained submodules. |
| 87 | + |
| 88 | +Update tracking submodules to tip of branch:: |
| 89 | + Retrieve the tip of the configured branch in .gitmodules. |
| 90 | + |
| 91 | +Use credentials from default remote of parent repository:: |
| 92 | + Use credentials from the default remote of the parent project. |
| 93 | + Submodule updates do not use credentials by default. |
| 94 | + Enabling this extension will provide the parent repository credentials to each of the submodule repositories. |
| 95 | + Submodule credentials require that the submodule repository must accept the same credentials as the parent project. |
| 96 | + If the parent project is cloned with https, then the authenticated submodule references must use https as well. |
| 97 | + If the parent project is cloned with ssh, then the authenticated submodule references must use ssh as well. |
| 98 | + |
| 99 | +Shallow clone:: |
| 100 | + Perform shallow clone of submodules. |
| 101 | + Git will not download the complete history of the project, saving time and disk space. |
| 102 | + |
| 103 | +Shallow clone depth:: |
| 104 | + Set shallow clone depth for submodules. |
| 105 | + Git will only download recent history of the project, saving time and disk space. |
| 106 | + |
| 107 | +Path of the reference repo to use during submodule update:: |
| 108 | + Folder containing a repository that will be used by git as a reference during submodule clone operations. |
| 109 | + This option will be ignored if the folder is not available on the agent running the build. |
| 110 | + A reference repository may contain multiple subprojects. |
| 111 | + See the [combining repositories](#combining-repositories) section for more details. |
| 112 | + |
| 113 | +Timeout (in minutes) for submodules operations:: |
| 114 | + Specify a timeout (in minutes) for submodules operations. |
| 115 | + This option overrides the default timeout. |
| 116 | + |
| 117 | +Number of threads to use when updating submodules:: |
| 118 | + Number of parallel processes to be used when updating submodules. |
| 119 | + Default is to use a single thread for submodule updates |
| 120 | + |
| 121 | +### Calculate changelog against a specific branch |
| 122 | + |
| 123 | +Name of repository:: |
| 124 | + Name of the repository, such as origin, that contains the branch. |
18 | 125 |
|
19 | | -Plugin source code is hosted on [GitHub](https://github.com/jenkinsci/git-plugin). |
20 | | -New feature proposals and bug fix proposals should be submitted as |
21 | | -[pull requests](https://help.github.com/articles/creating-a-pull-request). |
22 | | -Fork the repository, prepare your change on your forked |
23 | | -copy, and submit a pull request to the master branch. Your pull request will be evaluated |
24 | | -by the [Jenkins job](https://ci.jenkins.io/job/Plugins/job/git-plugin/). |
| 126 | +Name of branch:: |
| 127 | + Name of the branch used for the changelog calculation within the named repository. |
25 | 128 |
|
26 | | -Before submitting your pull request, please add tests which verify your |
27 | | -change. There have been many developers involved in the git plugin and |
28 | | -there are many users who depend on the git plugin. Tests help us assure |
29 | | -that we're delivering a reliable plugin, and that we've communicated |
30 | | -our intent to other developers in a way that they can detect when they |
31 | | -run tests. |
| 129 | +### Checkout to a sub-directory |
32 | 130 |
|
33 | | -Code coverage reporting is available as a maven target and is actively |
34 | | -monitored. Please improve code coverage with the tests you submit. |
35 | | -Code coverage reporting is written to `target/site/jacoco/` by the maven command: |
| 131 | +Specify a local directory (relative to the workspace root) where the git repository will be checked out. |
| 132 | +If left empty, the workspace root itself will be used. |
36 | 133 |
|
| 134 | +### Checkout to specific local branch |
| 135 | + |
| 136 | +Branch name:: |
| 137 | + If given, checkout the revision to build as HEAD on the named branch. |
| 138 | + If value is an empty string or "**", then the branch name is computed from the remote branch without the origin. |
| 139 | + In that case, a remote branch origin/master will be checked out to a local branch named master, and a remote branch origin/develop/new-feature will be checked out to a local branch named develop/newfeature. |
| 140 | + |
| 141 | +### Clean after checkout |
| 142 | + |
| 143 | +Clean the workspace **after** every checkout by deleting all untracked files and directories, including those which are specified in .gitignore. |
| 144 | +Resets all tracked files to their versioned state. |
| 145 | +Ensures that the workspace is in the same state as if cloned and checkout were performed in a new workspace. |
| 146 | +Reduces the risk that current build will be affected by files generated by prior builds. |
| 147 | +Does not remove files outside the workspace (like temporary files or cache files). |
| 148 | +Does not remove files in the `.git` repository of the workspace. |
| 149 | + |
| 150 | +### Clean before checkout |
| 151 | + |
| 152 | +Clean the workspace **before** every checkout by deleting all untracked files and directories, including those which are specified in .gitignore. |
| 153 | +Resets all tracked files to their versioned state. |
| 154 | +Ensures that the workspace is in the same state as if cloned and checkout were performed in a new workspace. |
| 155 | +Reduces the risk that current build will be affected by files generated by prior builds. |
| 156 | +Does not remove files outside the workspace (like temporary files or cache files). |
| 157 | +Does not remove files in the `.git` repository of the workspace. |
| 158 | + |
| 159 | +### Create a tag for every build |
| 160 | + |
| 161 | +Create a tag in the workspace for every build to unambiguously mark the commit that was built. |
| 162 | +You can combine this with Git publisher to push the tags to the remote repository. |
| 163 | + |
| 164 | +### Custom SCM name - __Deprecated__ |
| 165 | + |
| 166 | +Unique name for this SCM. |
| 167 | +Was needed when using Git within the Multi SCM plugin. |
| 168 | +Pipeline is the robust and feature-rich way to checkout from multiple repositories in a single job. |
| 169 | + |
| 170 | +### Custom user name/e-mail address |
| 171 | + |
| 172 | +user.name:: |
| 173 | + Defines the user name value which git will assign to new commits made in the workspace. |
| 174 | + If given, `git config user.name [this]` is called before builds. |
| 175 | + This overrides values from the global settings. |
| 176 | + |
| 177 | +user.email:: |
| 178 | + Defines the user email value which git will assign to new commits made in the workspace. |
| 179 | + If given, `git config user.email [this]` is called before builds. |
| 180 | + This overrides whatever is in the global settings. |
| 181 | + |
| 182 | +// ### Don't trigger a build on commit notifications |
| 183 | +// ### Force polling using workspace |
| 184 | +// ### Git LFS pull after checkout |
| 185 | +// ### Merge before build |
| 186 | +// ### Polling ignores commits from certain users |
| 187 | +// ### Polling ignores commits in certain paths |
| 188 | +// ### Polling ignores commits with certain messages |
| 189 | + |
| 190 | +### Prune stale remote tracking branches |
| 191 | + |
| 192 | +Runs `git remote prune` for each remote to prune obsolete local branches. |
| 193 | + |
| 194 | +// ### Sparse checkout paths |
| 195 | +// ### Strategy for choosing what to build |
| 196 | + |
| 197 | +### Use commit author in changelog |
| 198 | + |
| 199 | +The default behavior is to use the Git commit's "Committer" value in build changesets. |
| 200 | +If this option is selected, the git commit's "Author" value is used instead. |
| 201 | + |
| 202 | +// ### Wipe out repository and force clone |
| 203 | + |
| 204 | +## Environment Variables |
| 205 | + |
| 206 | +## Properties |
| 207 | + |
| 208 | +Some git plugin settings can only be controlled from command line properties set at Jenkins startup. |
| 209 | + |
| 210 | +Default timeout:: |
| 211 | + The default initial git timeout value can be overridden through the property `org.jenkinsci.plugins.gitclient.Git.timeOut` (see [JENKINS-11286](https://issues.jenkins-ci.org/browse/JENKINS-11286)). |
| 212 | + The property should be set on both master and agent to have effect (see [JENKINS-22547](https://issues.jenkins-ci.org/browse/JENKINS-22547)). |
| 213 | + |
| 214 | +// ## Pipelines |
| 215 | + |
| 216 | +// ## Performance Tuning |
| 217 | + |
| 218 | +// ### Reference repositories |
| 219 | + |
| 220 | +### Combining repositories |
| 221 | + |
| 222 | +A single reference repository may contain commits from multiple repositories. |
| 223 | +For example, if a repository named `parent` includes references to submodules `child-1` and `child-2`, a reference repository could be created to cache commits from all three repositories using the commands: |
37 | 224 | ``` |
38 | | - $ mvn -P enable-jacoco clean install jacoco:report |
| 225 | +$ mkdir multirepository-cache.git |
| 226 | +$ cd multirepository-cache.git |
| 227 | +$ git init --bare |
| 228 | +$ git remote add parent https://github.com/jenkinsci/git-plugin |
| 229 | +$ git remote add child-1 https://github.com/jenkinsci/git-client-plugin |
| 230 | +$ git remote add child-2 https://github.com/jenkinsci/platformlabeler-plugin |
| 231 | +$ git fetch --all |
39 | 232 | ``` |
40 | 233 |
|
41 | | -Before submitting your change, review the spotbugs output to |
42 | | -assure that you haven't introduced new spotbugs warnings. |
| 234 | +Those commands will create a single bare repository which includes the current commits from all three repositories. |
| 235 | +If that reference repository is used in the advanced clone options <<clone-reference-repository-path>>, it will reduce data transfer and disc use for the parent repository. |
| 236 | +If that reference repository is used in the submodule options <<submodule-reference-repository-path>>, it will reduce data transfer and disc use for the submodule repositories. |
43 | 237 |
|
44 | | -## Building the Plugin |
| 238 | +## Bug Reports |
45 | 239 |
|
46 | | -```bash |
47 | | - $ java -version # Need Java 1.8 |
48 | | - $ mvn -version # Need a modern maven version; maven 3.5.4 or later are required |
49 | | - $ mvn clean install |
50 | | -``` |
| 240 | +Report issues and enhancements in the [Jenkins issue tracker](https://issues.jenkins-ci.org). |
51 | 241 |
|
52 | | -## To Do |
| 242 | +## Contributing to the Plugin |
53 | 243 |
|
54 | | -* Fix [bugs](https://issues.jenkins-ci.org/secure/IssueNavigator.jspa?mode=hide&reset=true&jqlQuery=project+%3D+JENKINS+AND+status+in+%28Open%2C+"In+Progress"%2C+Reopened%29+AND+component+%3D+git-plugin) |
55 | | -* Improve code coverage |
56 | | -* Improve javadoc |
| 244 | +Refer to [contributing to the plugin](CONTRIBUTING.md) for contribution guidelines. |
0 commit comments