You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-37Lines changed: 39 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ you require the following plugins:
14
14
* GitLab Branch Source Plugin - Contains two packages:
15
15
16
16
*`io.jenkins.plugins.gitlabserverconfig` - Manages server configuration and web hooks management. Ideally should reside inside another plugin with name `GitLab Plugin`. In future, this package will be moved into a new plugin.
17
-
17
+
18
18
*`io.jenkins.plugins.gitlabbranchsource` - Adds GitLab Branch Source for Multi-branch Pipeline Jobs (including
19
19
Merge Requests) and Folder organization.
20
20
@@ -83,7 +83,7 @@ Here are a few ways to setup your own Jenkins server:
83
83
Refer to Bitnami [docs](https://docs.bitnami.com/general/apps/jenkins/).
84
84
85
85
5. Using [Jenkins CLI](https://github.com/jenkins-zh/jenkins-cli) run it for development:
86
-
86
+
87
87
Run it via: `jcli plugin run`
88
88
89
89
### Configuring Jenkins instance:
@@ -121,7 +121,7 @@ Here are a few ways to setup your own Jenkins server:
121
121
You can use any one of these ways:
122
122
123
123
1. Install from Jenkins Update Center. Go to Jenkins > Configure > Manage Plugins > Available and search for`gitlab branch source plugin`thenselectInstall.
124
-
124
+
125
125
2. Using [Plugin Management Tool](https://github.com/jenkinsci/plugin-installation-manager-tool)
126
126
127
127
```bash
@@ -134,12 +134,12 @@ You can use any one of these ways:
134
134
3. From Source:
135
135
136
136
i. Checkout out source code to your local machine:
@@ -148,7 +148,7 @@ You can use any one of these ways:
148
148
```
149
149
150
150
iii. Run the Plugin:
151
-
151
+
152
152
```
153
153
mvn hpi:run # runs a Jenkins instance at localhost:8080
154
154
or
@@ -201,9 +201,9 @@ After installing the plugin on your Jenkins instance, you need configure your Gi
201
201
202
202
iii. `Credentials` - Contains a list of credentials entries that are of type GitLab Personal Access Token. When no credential has been added it shows "-none-". User can add a credential by clicking "Add" button.
203
203
204
-
iv. `Mange Web Hook` - If you want the plugin to setup web hook on your GitLab project(s) to get push/mr/tag/note events then check this box.
205
-
206
-
iv. `Mange System Hook` - If you want the plugin to setup system hook on your GitLab project(s) to detect if a project is removed then check this box. Remember plugin can only setup system hook on your server if supplied access token has `Admin` access.
204
+
iv. `Mange Web Hook` - If you want the plugin to setup web hook on your GitLab project(s) to get push/mr/tag/note events then check this box.
205
+
206
+
iv. `Mange System Hook` - If you want the plugin to setup system hook on your GitLab project(s) to detect if a project is removed then check this box. Remember plugin can only setup system hook on your server if supplied access token has `Admin` access.
207
207
208
208
v. `Secret Token` - The secret token is required to authenticate the webhook payloads received from GitLab Server. Use generate secret token from Advanced options or use your own. If you are a old plugin user and did not set a secret token previously and want secret token to applied to the hooks of your existing jobs, you can add the secret token and rescan your jobs. Existing hooks with new secret token will be applied.
209
209
@@ -283,7 +283,7 @@ GitLab Personal Access Token credentials to Jenkins server credentials.
283
283
7. The token creator will create a Personal Access Token in your GitLab Server for the given user with the required scope and also create a credentials for the same inside Jenkins server. You can go back to the GitLab Server Configuration to selectthe new credentials generated (select "-none-" first then new credentials will appear). For security reasons this token is not revealed as plain text rather returns an `id`. It is a 128-bit long UUID-4 string (36 characters).
Use the following end points for web hooks and system hooks setup on your GitLab Server. The `Jenkins Url` needs to be a fully qualified domain name (FQDN) so cannot be `localhost`.
@@ -379,17 +379,17 @@ To create a `Multibranch Pipeline Job`:
379
379
3. In `Branch Sources` sections, select`Add source`|select`GitLab Project`.
380
380
381
381
4. Now you need to configure your jobs.
382
-
382
+
383
383

384
-
384
+
385
385
i. Select `Server` configured in the initial server setup.
386
-
386
+
387
387
ii. [Optional] Add `Checkout Credentials` (SSHPrivateKey or Username/Password) if there is any private projects that will be built by the plugin.
388
-
388
+
389
389
iii. Add path to the owner where the project you want to build exists. If user, enter `username`. If group, enter `group name`. If subgroup, enter `subgroup path with namespace`.
390
-
390
+
391
391
iv. Based on the owner provided. All the projects are discovered in the path and added to the `Projects` listbox. You can now choose the project you want to build.
392
-
392
+
393
393
v. `Behaviours` (a.k.a. SCM Traits) allow different configurations option to your build. More about it in the SCM Trait APIs section.
394
394
395
395
5. Now you can go ahead and save the job.
@@ -402,7 +402,7 @@ The Job results are notified to the GitLab Server as Pipeline Status for the HEA
402
402
403
403
We have a workaround for this. Jenkins will build the MRs from forked projects if the MR author is a trusted owner i.e. has `Developer`/`Maintainer`/`Owner` access level. More about it in the SCM Trait APIs section.
404
404
405
-
As the web hook is now setup on your Jenkins CI by the GitLab server. Any push-events or merge-request events or tag events trigger the concerned build in Jenkins.
405
+
As the web hook is now setup on your Jenkins CI by the GitLab server. Any push-events or merge-request events or tag events trigger the concerned build in Jenkins.
406
406
407
407
### Folder Organization
408
408
@@ -415,7 +415,7 @@ To create a `GitLab Group Job`:
415
415
2. Enter a name for your job, select `GitLab Group` | select `Ok`.
416
416
417
417
3. Now you need to configure your jobs.
418
-
418
+
419
419
i. Select `Server` configured in the initial server setup.
420
420
421
421
ii. [Optional] Add `Checkout Credentials` (SSHPrivateKey or Username/Password) only if there are any private projects required to be built.
@@ -439,26 +439,26 @@ The following behaviours apply to both `Multibranch Pipeline Jobs` and `Folder O
439
439
* `All Branches` - Ignores whether the branch is also filed as a merge request and instead discovers all branches on the origin project.
440
440
441
441
* `Discover merge requests from origin` - To discover merge requests made from origin branches.
442
-
442
+
443
443
* `Merging the merge request merged with current target revision` - Discover each merge request once with the discovered revision corresponding to the result of merging with the current revision of the target branch.
444
444
* `The current merge request revision` - Discover each merge request once with the discovered revision corresponding to the merge request head revision without merging.
445
445
* `Both current mr revision and the mr merged with current target revision` - Discover each merge request twice. The first discovered revision corresponds to the result of merging with the current revision of the target branch in each scan. The second parallel discovered revision corresponds to the merge request head revision without merging.
446
446
447
447
* `Discover merge requests from forks` - To discover merge requests made from forked project branches.
448
448
449
449
* Strategy:
450
-
450
+
451
451
* `Merging the merge request merged with current target revision` - Discover each merge request once with the discovered revision corresponding to the result of merging with the current revision of the target branch.
452
452
* `The current merge request revision` - Discover each merge request once with the discovered revision corresponding to the merge request head revision without merging.
453
453
* `Both current mr revision and the mr merged with current target revision` - Discover each merge request twice. The first discovered revision corresponds to the result of merging with the current revision of the target branch in each scan. The second parallel discovered revision corresponds to the merge request head revision without merging.
454
-
454
+
455
455
* Trust
456
-
456
+
457
457
* `Members` - Discover MRs from Forked Projects whose author is a member of the origin project.
458
458
* `Trusted Members` - [Recommended] Discover MRs from Forked Projects whose author is has Developer/Maintainer/Owner accesslevel in the origin project.
459
459
* `Everyone` - Discover MRs from Forked Projects filed by anybody. For security reasons you should never use this option. It may be used to reveal your Pipeline secrets environment variables.
460
460
* `Nobody` - Discover no MRs from Forked Projects at all. Equivalent to removing the trait altogether.
461
-
461
+
462
462
If `Members` or `Trusted Members` is selected, then plugin will build the target branch of MRs from non/untrusted members.
463
463
464
464
### Additional Traits:
@@ -469,7 +469,7 @@ These traits can be selected by selecting `Add` in the `Behaviours` section.
469
469
470
470
* `Discover group/subgroup projects` - Discover subgroup projects inside a group/subgroup. Only applicable to `GitLab Group` Job type whose owner is a `Group`/`Subgroup` but not `User`.
471
471
472
-
* `Log build status as comment on GitLab` - Enable logging build status as comment on GitLab. A comment is logged on the commit or merge request once the build is completed. You can decide if you want to log success builds or not. You can also use sudo user to comment the build status as commment e.g. `jenkinsadmin` or something similar.
472
+
* `Log build status as comment on GitLab` - Enable logging build status as comment on GitLab. A comment is logged on the commit or merge request once the build is completed. You can decide if you want to log success builds or not. You can also use sudo user to comment the build status as commment e.g. `jenkinsadmin` or something similar.
473
473
474
474
* `Trigger build on merge request comment` - Enable trigger a rebuild of a merge request by comment with your desired comment body (default: `jenkins rebuild`). The job can only be triggered by trusted members of the project i.e. users with Developer/Maintainer/Owner accesslevel (also includes inherited from ancestor groups). By default only trusted members of project can trigger MR.
475
475
You may want to disable this option because trusted members do not include members inherited from shared group (there is no way to get it from GitLabApi as of GitLab 13.0.0). If disabled, MR comment trigger can be done by any user having access to your project.
@@ -488,6 +488,8 @@ You may want to disable this option because trusted members do not include membe
488
488
489
489
* `Checkout over SSH` - [Not Recommended] Use this mode to checkout over SSH. Use `Checkout Credentials` instead.
490
490
491
+
* `Webhook Listener Conditions` - Set conditions based on the webhook content on when a build should be triggered.
492
+
491
493
## Environment Variables
492
494
493
495
By default Multibranch Jobs have the following environment variables (provided by Branch API Plugin):
Tag - `BRANCH_NAME`, `TAG_NAME`, `TAG_TIMESTAMP`, `TAG_DATE`, `TAG_UNIXTIME`
500
502
501
-
This plugin adds a few more environment variables to Builds (`WorkflowRun` type only) which is the payload received as WebHook) See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#events.
503
+
This plugin adds a few more environment variables to Builds (`WorkflowRun` type only) which is the payload received as WebHook) See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#events.
502
504
503
-
A few points to note:
505
+
A few points to note:
504
506
505
507
> If no response is recorded for any field in the Web Hook Payload, it returns an empty String. To add more variables see `package io.jenkins.plugins.gitlabbranchsource.Cause`.
506
-
>
508
+
>
507
509
> `GITLAB_OBJECT_KIND` - This environment variable should be used to check the event type before accessing the environment variables. Possible values are `none`, `push`, `tag_push` and `merge_request`.
508
510
>
509
511
> Any variables ending with `#` indicates the index of the list of the payload starting from 1.
510
512
511
513
Environment Variables are available from Push Event, Tag Push Event and Merge Request Event.
512
514
513
-
### Push Event:
515
+
### Push Event:
514
516
515
517
See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#push-events
516
518
@@ -561,12 +563,12 @@ GITLAB_REFS_HEAD
561
563
562
564
### Tag Event:
563
565
564
-
Note:
565
-
> Jenkins by default refrains from automatically building Tags on push ([See reason](https://issues.jenkins-ci.org/browse/JENKINS-47496?focusedCommentId=332369&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-332369)). You need to install Branch Build Strategy Plugin to solve this.
566
-
>
566
+
Note:
567
+
> Jenkins by default refrains from automatically building Tags on push ([See reason](https://issues.jenkins-ci.org/browse/JENKINS-47496?focusedCommentId=332369&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-332369)). You need to install Branch Build Strategy Plugin to solve this.
568
+
>
567
569
> See Guide: https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/docs/user.adoc
568
570
>
569
-
> Do remember if you are using Basic Branch Build for tag builds you also need to add strategies for branch and pull request (change request) else they would not be automatically built (See GIF below).
571
+
> Do remember if you are using Basic Branch Build for tag builds you also need to add strategies for branch and pull request (change request) else they would not be automatically built (See GIF below).
0 commit comments