As of opf/openproject#14881 this plugin was merged into OpenProject core v13.4. Hence, further changes or improvements will be made directly within OpenProject.
Already using the user-generated GitLab plugin? With OpenProject 13.4, the existing plugin will be replaced by the new integration. We recommend removing the plugin module folder and bundler references before upgrading to openproject. Your historical dataset will remain unaffected within OpenProject as there were no changes to the data model.
Before upgrading, please do the following:
- Remove traces of gitlab integration in your Gemfile.lock and Gemfile.modules See Configuration section
- Remove the module code traces of the gitlab integration.
rm -rf /path/to/openproject/modules/gitlab_integration
Many thanks to everyone who worked on this plugin – inside and outside of OpenProject's core development team! Such projects are a great example of the power of open source collaboration.💙
Based on the OpenProject Github Integration, this plugin offers the same functionalities plus other new features. This is the first version that includes the visualization of the status of the Pipelines (by now, it is considered in Beta status). You can test it by activating the Pipelines event in the GitLab webhook. Just keep in mind that not all pipelines will be reflected in OpenProject, only Merge Request type pipelines (for more information see the GitLab issue https://gitlab.com/gitlab-org/gitlab/-/issues/345028). Any feedback about the pipelines feature would be very appreciated, whether it works or if issues arise (you can use this ticket btey#43).
In this version it has also been implemented that all linked or referenced Issues appear in the GitLab tab (btey#34). The opportunity has also been taken to redesign how the information is presented so that it is visually easy to read and at the same time can continue to provide all the information, including labels and pipeline status.
If there are labels related to the Issue or MR, a button with the label icon will appear. By clicking the button you can show/hide the associated labels.
OpenProject module for integration with GitLab:
- Latest Gitlab release tested: 16.6.2
- Latest OpenProject release tested: 13.1.2 (for OP v13.0.X use v2.1.2)
The reference system is based on the same system as for GitHub integration. You can use a link to the work package or just use “OP#87” or "PP#87" in the title/description of the Issue/MR in GitLab.
Note about the references. Whether or not to include the reference in certain places depends on the information that GitLab sends through its webhook. If you include the reference in the title/description of an issue, the comments on the issue do not need to include the reference. The same will happen when you generate a Merge Request based on an Issue that already includes the reference; comments from that MR need not include the reference.
If you use OP#
as a reference in an Issue or MR title, all comments will be replicated in OpenProject. However, sometimes you may only want to keep information about the status of an Issue/MR in OpenProject, but you don't want your comments to be published. In this case, you can use PP#
as a reference. This way the comments will not be published in OpenProject. But if at any time one of your comments in a private Issue/MR is of interest to you to be published in OpenProject you can use OP#
directly in that comment. So only that comment will be published in OpenProject. The rest of the comments will remain private and will not be published.
OpenProject will add comments to work package for the following events:
- Merge Request (Opened, Closed and Merged)
- Issue (Opened, Closed)
- Push commits in Merge Requests
- Since v2.1.5 of the plugin you can activate system hooks for Push events.
- Comments (on Issues, Merge Request, Commits and Snippets)
- Pipelines (Beta feature)
OpenProject will update WP status in this events:
- Merge Request (opened) - Status: In progress (currently ID=7)
- Merge Request (merged) - Status: Developed (currently ID=8)
Note about the status. If you want to change the ID of the status you can do this in this section of the code. By default is disabled, you can enable it by setting to
true
this lines.
A typical workflow on GitLab side would be:
-
Create Issue.
Issue Opened: Issue 6 New contact form - OP#18 for Scrum project has been opened by Administrator.
-
Comment on issue.
If the reference is included in the title, the comments will not need a reference. By default, all comments will use the title as a reference.
Commented in Issue: Administrator commented this WP in Issue 6 New contact form - OP#18 on Scrum project:
New comment on the issue with attachment.
-
Create Merge Request.
MR Opened: Merge request 25 Draft: Resolve "New contact form - OP#18" for Scrum project has been opened by Administrator.
Status changed from Specified to In progress
-
Comment in Merge Request.
Commented in MR: Administrator commented this WP in Merge request 25 Draft: Resolve "New contact form - OP#18" on Scrum project:
New comment on MR.
-
Reference in other Issues or Merge Request (comments).
If the reference is NOT included in the title of the Issue/MR, the comments will need a reference. In OpenProject the comment will be saved as "referenced" in Issue/MR.
Referenced in Issue: Administrator referenced this WP in Issue 2 New backend pipeline on Scrum project:
OP#18 New comment about...
Note: If you use the reference
PP#
in the title of the Issue/MR, you can useOP#
in the comment to generate the same type of comment in OpenProject. -
New commit in Merge Request.
Pushed in MR: Administrator pushed fca3d6fb to Scrum project at 2021-03-08T08:01:57+00:00:
Update readme.md OP#18
-
Comment in a new commit of the Merge Request.
Referenced in Commit: Administrator referenced this WP in a Commit Note 0bf0e3e9 on Scrum project:
This change is for OP#18.
-
Merge Request merged (generates up to 3 events).
Pushed in MR: Administrator pushed 1da09cb4 to Scrum project at 2021-03-05T14:57:37+00:00:
Merge branch '5-new-contact-form-op-18' into 'master'
Resolve "New contact form - OP#18"
Closes #6
See merge request root/scrum!9
MR Merged: Merge request 24 Resolve "New contact form - OP#18" for Scrum project has been merged by Administrator.
Status changed from In progress to Developed
Issue Closed: Issue 6 New contact form - OP#18 for Scrum project has been closed by Administrator.
You will have to configure both OpenProject and Gitlab for the integration to work.
In case of Docker installation, follow the official OpenProject documentation here. If for some reason the installation with Docker described in the official documentation does not work for you, you can try building your own docker image:
- Clone from the Openproject Repo:
git clone https://github.com/opf/openproject.git --branch=stable/13 --depth=1 .
- Clone the plugin inside the modules folder:
git clone https://github.com/btey/openproject-gitlab-integration.git --depth=1 modules/gitlab_integration
- Apply the changes below in Gemfile.lock and Gemfile.modules (the same ones you would do in a manual install).
- Build the container:
docker build -t openproject-docker --file=docker/prod/Dockerfile .
- Now run the image following the official documentation.
In case of DEB/RPM based instalation, follow the official OpenProject documentation here.
In case of manual installation, this plugin should be installed in the same place as the Github plugin that comes bundled with OpenProject.
-
Github plugin path:
modules/github_integration
-
Path to put Gitlab plugin:
modules/gitlab_integration
But first you must modify Gemfile.lock and Gemfile.modules so that OpenProject detects the new module.
Add the following in Gemfile.lock:
PATH
remote: modules/gitlab_integration
specs:
openproject-gitlab_integration (2.1.6)
openproject-webhooks
And add this other line in DEPENDENCIES section:
DEPENDENCIES
...
openproject-github_integration!
openproject-gitlab_integration!
openproject-job_status!
...
Add the following in Gemfile.modules:
group :opf_plugins do
...
gem 'openproject-gitlab_integration', path: 'modules/gitlab_integration'
...
end
Note: It's possible that you need to use these commands before and after the bundle install
if you get an error in this step warning about a change in the Gemfile:
bundle config unset deployment
bundle install --deployment --without mysql2 sqlite development test therubyracer docker
bundle config set deployment
First you will need to create a user in OpenProject that will make the comments. The user will have to be added to each project with a role that allows them to comment on work packages and change status.
Once the user is created you need to generate an OpenProject API token for it to use later on the Gitlab side:
- Login as the newly created user.
- Go to My Account (click on Avatar in top right corner).
- Go to Access Token.
- Click on generate in the API row.
- Copy the generated key. You can now configure the necessary webhook in Gitlab.
In GitLab you have to set up a webhook in each project or in a group (Premium Users) to be integrated with OpenProject.
You need to configure just two things in the webhook:
-
The URL must point to your OpenProject server’s GitLab webhook endpoint (/webhooks/gitlab). Append it to the URL as a simple GET parameter named key. In the end the URL should look something like this:
http://openproject-url.com/webhooks/gitlab?key=[previous_generated_access_token_key]
-
Enable the required triggers:
- Push events (project hooks or systems hooks)
- Comments
- Issues events
- Merge request events
- Pipeline events
Now the integration is set up on both sides and you can use it.
Note: If you are installing and configuring OpenProject on the same server as GitLab you will need to enable in Gitlab the option
Allow requests to the local network from web hooks and services
so that it can send the data locally to the OpenProject webhook since they will be on the same machine.
Any error, bug or issue can be reported by creating a new issue.