Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a Modern Mode handling for merge requests. #285

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c862248
Adds a Modern Mode handling for merge requests. In Modern Mode, the p…
pbendersky Apr 28, 2016
238653b
Fixes for compatibility with latest master changes
pbendersky May 2, 2016
ffdb6a5
Updated for compatibility with latest changes
pbendersky May 2, 2016
2418141
Removed unused import of hudson.model.AbstractBuild
pbendersky May 2, 2016
91db58f
Updated README with Modern / Legacy explanation
pbendersky May 3, 2016
93bdb85
Merge branch 'master' into merge-requests-1.2
pbendersky May 4, 2016
1ddb319
Merge remote-tracking branch 'upstream/master' into merge-requests-1.2
pbendersky May 4, 2016
e8fc119
Merge branch 'master' into merge-requests-1.2
pbendersky May 9, 2016
3837e63
Fixed issue with Commit Status Updater where it would crash if the bu…
pbendersky May 9, 2016
3f08ce5
Merge branch 'master' into merge-requests-1.2
pbendersky May 12, 2016
692a9c3
- Merged master from upstream.
pbendersky May 19, 2016
c18f68b
Fixed readme
pbendersky May 19, 2016
a420f6a
Merged latest changes in master
pbendersky May 26, 2016
112fcc9
- Updated Readme to reflect that Modern Mode doesn't support re-build…
pbendersky Jun 6, 2016
59ed129
Merge branch 'master' into merge-requests-1.2
pbendersky Jun 6, 2016
697e991
Merge branch 'master' into merge-requests-1.2
pbendersky Jun 7, 2016
27c4225
Changed target to source
pbendersky Jun 7, 2016
8b99102
Merge branch 'master' into merge-requests-1.2
pbendersky Jun 22, 2016
a2ff6e4
fixed issues after merging
pbendersky Jun 22, 2016
8c14ffa
Merge branch 'master' into merge-requests-1.2
pbendersky Jun 29, 2016
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
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
- [Parameterized builds](#parameterized-builds)
- [Branch filtering](#branch-filtering)
- [Build Tags](#build-tags)
<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you committed the merge conflicts of README...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just added a new commit fixing it.

- [Contributing to the Plugin](#contributing-to-the-plugin)
=======
- [Parameterized builds](#parameterized-builds)
>>>>>>> master
- [Quick test environment setup using Docker](#quick-test-environment-setup-using-docker)
- [Access GitLab](#access-gitlab)
- [Access Jenkins](#access-jenkins)
Expand Down Expand Up @@ -128,7 +132,13 @@ You can trigger a build manually from Jenkins. By default, it will fetch from `o
* Set *Name of the repository" to ``origin``
* Set *Branch to merge* as ``${gitlabTargetBranch}``

<<<<<<< HEAD
#### Git configuration for Pipeline/Workflow jobs
=======
**Note:** Since version **1.2.0** the *gitlab-plugin* sets the gitlab hook values through *environment variables* instead of *build parameters*. To set default values, consult [EnvInject Plugin](https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin).

### Git configuration for Pipeline/Workflow jobs
>>>>>>> master
**Incompatibility note:** When upgrading to version 1.2.1 or later of the plugin, if you are using Pipeline jobs you will need to manually reconfigure your Pipeline scripts. In older versions the plugin set global Groovy variables that could be accessed as e.g. ${gitlabSourceBranch}. After version 1.2.1, these variables are only accessible in the env[] map. E.g. ${env.gitlabSourceBranch}.

* A Jenkins Pipeline bug will prevent the Git clone from working when you use a Pipeline script from SCM. It works if you use the Jenkins job config UI to edit the script. There is a workaround mentioned here: https://issues.jenkins-ci.org/browse/JENKINS-33719
Expand Down Expand Up @@ -197,7 +207,25 @@ In addition, you will need to make sure that the Git plugin has an appropriate s
1. Click on Manage Jenkins, then Configure System
2. Under the Git Plugin section, set something for 'Global Config user.name Value' and 'Global Config user.email Value'

<<<<<<< HEAD
### Parameterized builds
=======
# Branch filtering

Triggers may be filtered based on the branch name, i.e. the build will only be allowed for selected branches. On the project configuration page, when you configure the GitLab trigger, you can choose 'Filter branches by name' or 'Filter branches by regex.' Filter by name takes comma-separated lists of branch names to include and/or exclude from triggering a build. Filter by regex takes a Java regular expression to include and/or exclude.

**Note:** This functionality requires accessing the GitLab server (see [above](#configuring-access-to-gitlab)) and for the time being also a git repository url already saved in the project configuration. In other words, when creating a new project, the configuration needs to be saved *once* before being able to select the allowed branches. For Workflow/Pipeline jobs, the configuration must be saved *and* the job must be run once before the list is populated. For existing projects, all branches are allowed to push by default.

# Build Tags

In order to build when a new tag is pushed:
* In the ``GitLab server`` add ``Tag push events`` to the ``Web Hook``
* In the ``Jenkins`` under the ``Source Code Management`` section:
* select ``Advance...`` and add ``+refs/tags/*:refs/remotes/origin/tags/*`` as ``Refspec``
* you can also use ``Branch Specifier`` to specify which tag need to be built (exampple ``refs/tags/${TAGNAME}``)

# Parameterized builds
>>>>>>> master

You can trigger a job a manually by clicking ``This build is parameterized`` and adding the any of the relevant build parameters.
These include:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.dabsquared.gitlabjenkins;

/**
Expand All @@ -12,21 +7,4 @@
public enum GitLabPluginMode {
LEGACY,
MODERN;
/*
private final Class<? extends GitLabPluginStrategy> pushTriggerStrategyClass;

GitLabPluginMode(Class<? extends GitLabPluginStrategy> pushTriggerStrategyClass) {
this.pushTriggerStrategyClass = pushTriggerStrategyClass;
}

public GitLabPluginStrategy getGitLabPluginStrategy() {
try {
return this.pushTriggerStrategyClass.newInstance();
} catch (InstantiationException | IllegalAccessException ex) {
Logger.getLogger(GitLabPluginMode.class.getName()).log(Level.SEVERE, null, ex);
}

return null;
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public String getMergeRequestDescription() {
public Integer getMergeRequestId() {
return mergeRequestId;
}

public Integer getMergeRequestIid() {
return mergeRequestIid;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.dabsquared.gitlabjenkins.trigger.handler.merge;

import com.dabsquared.gitlabjenkins.cause.CauseData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ private AbstractBuild mockBuild(String sha, String buildUrl, String gitLabConnec
when(buildData.getLastBuiltRevision()).thenReturn(revision);
when(build.getCause(GitLabWebHookCause.class)).thenReturn(cause);
when(cause.getData()).thenReturn(causeData);
when(buildData.getRemoteUrls()).thenReturn(new HashSet<>(Arrays.asList(sourceRepoUrl, targetRepoUrl)));
Build gitBuild = mock(Build.class);
when(gitBuild.getMarked()).thenReturn(revision);
when(buildData.getLastBuild(any(ObjectId.class))).thenReturn(gitBuild);
when(build.getAction(BuildData.class)).thenReturn(buildData);
when(build.getResult()).thenReturn(result);
when(build.getUrl()).thenReturn(buildUrl);
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.