Giter VIP home page Giter VIP logo

gitlab-hook-plugin's Introduction

Jenkins GitLab Hook Plugin

Enables GitLab web hooks to be used to trigger SMC polling on GitLab projects
Plugin details can be found at https://wiki.jenkins-ci.org/display/JENKINS/Gitlab+Hook+Plugin

Why?

For GitLab there is an existing solution that might work for you.
You can just use the notifyCommit hook on Git plugin like this:

http://your-jenkins-server/git/notifyCommit?url=<URL of the Git repository for the GitLab project>

But, with a large number of projects that are mostly polling (no hooks), the project might actually be built with a great delay (5 to 20 minutes).
You can find more details about notifyCommit and this issue here.

That is where this plugin comes in.
It gives you the option to use build_now or notify_commit hook, whichever suits your needs better.

Build now hook

Add this web hook on your GitLab project:

http://your-jenkins-server/gitlab/build_now

Plugin will parse the GitLab payload and extract the branch for which the commit is being pushed and changes made.
It will then scan all Git projects in Jenkins and start the build for those that:

  • match url of the GitLab repo
  • match the configured refspec pattern if any
  • and match committed GitLab branch

Notes:

  • for branch comparison, it will take into account both the branch definition, the strategy and refspecs if defined (this is different from the original notifyCommit)
  • the project must be enabled
  • you don't have to setup polling for the project

Triggering a specific job

In case that payload parsing and automatic processing don't fit your need, it is still possible to setup the GitLab webhook to trigger a specific project as

http://your-jenkins-server/gitlab/build_now/project_name

When the hook is executed, the specified project will be triggered whichever way it is configured. In particular, neither the branch nor even the git url on payload must match those configured in the project. A typical use case is to get a simple method for tag building (taking advantage the fine grained available webhooks), or to trigger complex pipelines in jenkins, maybe using multijob or clone workspace plugins (look for example at JENKINS-29317 or JENKINS-29283 which motivated this feature).

Parameterized projects

The plugin will recognize projects that are parametrized and will use payload data to fill their values.
Only String and Choice parameter types are supported at this moment, all others are passed on with their defaults.
You can reference any data from the payload, including arrays and entire sections.
Here are a few examples:

Name Type Default Value Value In Build Note
USER_NAME String Default User John Smith From payload, first level, not using the default value
REPOSITORY.HOMEPAGE String - http://example.com/diaspora From payload, nested value
COMMITS.0.MESSAGE String - Update Catalan translation to e38cb41. From payload, nested value from array
COMMITS.1 String - { "id": "da1560886d4f...", ... } From payload, entire value from array
COMMITS.1.AUTHOR.NAME String - John Smith the Second From payload, entire value from nested value in array
cOmMiTs.1.aUtHoR.nAme String - John Smith the Second As above, case insensitive
FULL_BRANCH_REFERENCE String - refs/heads/master From details
BRANCH String - master From details

In case you define a parameter inside the branch specifier in Git configuration of the project, the plugin will replace the parameter value with the commit branch from the payload.
Replacing is done by matching ${PARAMETER_KEY} in the branch specifier to the parameter list for the project.

This is useful e.g. when you want to define a single project for all the branches in the repository.
Setup might look like this:

  • parametrized build with string parameter BRANCH_TO_BUILD, default = master
  • Source Code Management --> Branch specifier: origin/${BRANCH_TO_BUILD}

With this configuration, you have the following options:

  1. you can start a manual Jenkins build of a project, and it will ask for a branch to build
  2. for builds per commit using the GitLab build now hook, the branch parameter will be filled in with the commit branch extracted from the payload sent from GitLab

Advantages of this approach:

  • one Jenkins project per GitLab repository
  • builds all branches
  • no concurrent builds occur for the same GitLab repository

Disadvantages:

  • Jenkins can't resolve dependencies between Maven projects automatically because Jenkins projects reference different branches at different times
  • job / branch monitoring is not easy because all builds are contained within the same Jenkins project

Notify commit hook

NOTE: the notify commit feature is considered deprecated, and will be removed on a future version.

Add this web hook on your GitLab project:

http://your-jenkins-server/gitlab/notify_commit

The procedure is the same as for the build now hook, the difference is that this hook schedules polling of the project, much like the original notifyCommit.

Additional notes

This goes for both hooks:

  • the project must be configured not to skip notifyCommit
  • parametrized projects can be polled, but subsequent build will use the default parameter values (can't propagate the branch to the polling)

Delete branch commits

In case GitLab is triggering the deletion of a branch, the plugin will skip processing entirely unless automatic branch projects creation is enabled.
In that case, it will find the Jenkins project for that branch and delete it.
This applies only to non master branches (master is defined in plugin configuration).
Master branch project is never deleted.

Building tags

Although tags are static entities and as such seem unsensible in anything continuos, there are many scenarios where you would like to get some job done by Jenkins when any tag is pushed to GitLab. The main problem to accomplish this task is that wildcard handling by git plugin does not cover refs/tags/*, and we need specific extensions to handle this use case.

When incoming payload comes from the creation of a tag, the plugin parses the tag name and assings it to variable TAGNAME, that can be used on a parametrized job. So, setting the branch specifier to 'refs/tags/${TAGNAME}' the job will be executed for every tag.

Build status notifications

The plugin includes a publisher to inform GitLab about the build result that, when enabled, submits a comment with the build information. The default behaviour is to do only for merge requests, where the info will be shown on the discussion tab. It is possible to send the result for every commit built by Jenkins, unchecking Only submit status for merge projects on global configuration, which will post a commit comment.

Commit statuses

There is another way to sent this notifications, which requires a GitLab deployment patched with merge request 240. This change stores the commit status as a git note, and includes status visualization on the commits list view, among other places. When this extension is in use, status of merge requests is not posted as a comment, but rendered in the accept panel when CI build status service is enabled.

Automatic project creation

Create project for pushed branches

In case you might want to approach multiple branches by having a separate Jenkins project for each GitLab repository, you can turn on the appropriate plugin option. When enabled, if exists a Jenkins project that exactly maches the commited branch that project is build, and if no project exactly matches the commited branch, the plugin will

  1. copy the master project
  2. name the project according to the repository and commited branch name
  3. adjust SCM settings to reflect the commited branch and repository
  4. build the new project

Notes:

  • above mentioned "master" can be one of the following (determined in given order):
    • project that references the given repo url and master branch configured for plugin (defaults to "master")
    • project that references the given repo url for any other branch
  • a "master" project for the given repo is required to copy git settings, although templates functionality described below allow creation of Jenkins projects for new projects
  • everything you set on the master project will be copied to branch project, except that the copied project will track the payload commit branch and the project description, which is set based on plugin configuration
  • copying includes all parameters for the job. Note that branch parameters will be unused but not removed from job definition
  • the new project name is suffixed with the branch name, and depending on the value of "using master project name" configuration ng whether "using master project name" is enabled on plugin configuration
  • the new project name is constructed differently depending whether "using master project name" is enabled on plugin configuration, the first part will be the master project name or the repository name taken from payload
  • these projects will be automatically deleted if the tracking branch is deleted, as far as the project description is in sync with the one configured in the plugin

Advantages of this approach:

  • Jenkins can resolve dependencies between Maven projects automatically because Jenkins projects reference a single branch
  • job / branch monitoring is easier because a Jenkins project is related to a single branch
  • builds all branches

Disadvantages:

  • multiple Jenkins project per GitLab repository
  • concurrent builds occur for the same GitLab repository
  • job / branch monitoring is not easy because of a large number of projects for a single GitLab repository

For this option to become active, just turn it on in Jenkins global configuration.

Templates for unknown repositories

The plugin can be configured to automatically create projects when the hook is activated by a GitLab repo unknown to Jenkins. The template must be an existing Jenkins project, that could be an already running one or be specifically created for this purpose. The template can be a disabled project, because the brand new project will be enabled on creation. To enable this feature, supply values under the 'Advanced' part of the plugin section in the Jenkins global configuration page.

The simplest case is the last resort template, where a single template is used for every input webhook for an unknown project. To get finer clasification, distinct templates can also be assigned to different GitLab groups, which can be useful, for example, to handle android development based on gradle projects while the remaining java repositories are created with a maven template. Group matching is done using the exact group name.

The finest grained templating can be achieved with the repository name. It can be applied if you have in use some naming scheme for those repos. Payload for projects whose name starts with lib-java- could be redirected to a template that is prepared to publish the artifact on a public maven repository. Matching for this case is done based on leading text of the repository name.

Building of merge requests

The plugin is able to automatically create and delete projects for merge requests issued on GitLab. This behaviour is enabled by default, although it can be switched off in the global Jenkins configuration. If there is a project configured to build the target branch, a new project is created based on it, setting the branch specification with the merge request source branch, and properly enabling merge to option. Once created, any push to either source or target branch will cause a build of the project, which is named based on the original project and the merged branch, joined with "-mr-" for easy identification.

Dependencies

Logging

In case you might want to inspect hook triggering (e.g. to check payload data), you can setup logging in Jenkins as usual.
Just add a new logger for Class (this is because of JRuby internals).

Testing

To help with testing, the spec/lib directory contains all the Java dependencies the plugin uses directly. The spec_helper loads them before each test run. The package Rakefile behaviour changes depending on the platform used to run it. When executed under jruby, it runs the standard rspec examples, but when run on plain ruby starts a Jenkins instance and executes the acceptance tests.

No special options are required to execute the test on recent JRuby versions (such as 1.7.18)

Development

Locally building:

  • Download latest stable jruby tar
  • Extract and add bin/ directory to your $PATH
  • To install run: -- export GEM_HOME=~/.ruby/gems -- bundle install --path work/vendor/bundle
  • To build run jpi build

To test locally in Jenkins

  • Download latest Jenkins distribution
  • Extract and run java -jar jenkins.war
  • Upload pkg/gitlab-hook-nojenkinscommits.hpi into Jenkins manual install interface

Example post bodies are available on the gitlab webhook page

gitlab-hook-plugin's People

Contributors

danielcb avatar elvanja avatar guycheung avatar javiplx avatar manishval avatar nicoder avatar ssfinney avatar xaniasd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitlab-hook-plugin's Issues

Filter out commits by Jenkins git user

Hi, we have an issue where a git push from a Jenkins job is causing an endless loop, as the push triggers a new build.
I have forked and implemented a filter to ignore build_now pushes for a specific configured git user.

Would this be something you'd be interested in a pull request for?

I'd look at having it disabled by default and implementing it across other build causes.

Generated job name: customize or omit the prefix

I am testing this plugin for our Jenkins Gitlab integration. So long it works exactly the way we want, except one tiny issue.
I have configured the plugin to auto generate jobs for new branches. The name of the generated jobs seems bo be either "<template_job_name><branch_name>" or "<gitlab_project_name><branch_name>". I would like the job name to be simply "<branch_name>", but could not find out how to configure. Am I missing something obvious? Or could this be a new feature?

Not working with Jenkins 2.0 Pipeline plugin

Log says "WARNING: no project references the given repo url and commit branch"
However, I get all the normal spew leading up to the warning, such as..

INFO: gitlab web hook triggered for

  • repo url: [email protected]:redacted/redacted-reference-project.git
  • branch: master
  • with payload:
    {
    "object_kind": "push",
    "before": "2bd4bdf47f9752f7a178488554f06cc2682e8ff0",
    "after": "89ab9882dbe33e6e51336d7ecd63b66e94427a64",
    "ref": "refs/heads/master",
    etc etc..

So the web hook is triggered and it finds all the commits. It just fails at the end.

Running Jenkins 2.0

How parametrized build could be performed

in the doc it said,

In case you define a parameter inside the branch specifier in Git configuration of the project, the plugin will replace the parameter value with the commit branch from the payload.
Replacing is done by matching ${PARAMETER_KEY} in the branch specifier to the parameter list for the project.
This is useful e.g. when you want to define a single project for all the branches in the repository.
Setup might look like this:
parametrized build with string parameter BRANCH_TO_BUILD, default = master
Source Code Management --> Branch specifier: origin/${BRANCH_TO_BUILD}

it seems not work, and even didn't know where to go.
is any example for it, or could be some can explain the detail.

Thanks in advance.

Double quotes are not escaped in commit message

Context

Gitlab-Hook plugin version: 1.4.2
Gitlab version: 8.17.4
Jenkins version: 2.49

Problem description

We have some commit message with "double quotes". It results in ant build erroring out:

[code_analysis] $ ant -file ca_build.xml -DBRANCH_TO_BUILD=feature/revert -DCOMMITS.0.ID=e18c2a1305d54ba996a54b9e4c3e4e89bacb6d00 -Dtotal_commits_count=1 '-DCOMMITS.0.MESSAGE=Revert "feat: show notice when hour cost of wt unknown"

This reverts commit af2a1b4d50bca0473217b78b3816f2517bf9d771.'
Buildfile: /var/lib/jenkins/workspace/develop/build/code_analysis/ca_build.xml

BUILD FAILED
Target "show" does not exist in the project "CodeAnalysis". 

Can we somehow escape double quotes when sending a comit message from the gitlab to jenkins?

ERROR: load error: openssl -- java.lang.VerifyError

The plugin seems to cause runtime errors on a job execution:

ERROR: load error: openssl -- java.lang.VerifyError: (class: org/jruby/ext/openssl/X509Cert, method: sign signature: (Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;)Lorg/jruby/runtime/builtin/IRubyObject;) Incompatible argument to function (LoadError)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/lib/gitlab/client.rb:116:in `do_request'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/lib/gitlab/client.rb:87:in `repo_id'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/lib/gitlab/client.rb:19:in `name='
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/gitlab_notifier.rb:27:in `prebuild'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/tasks/build_step_proxy.rb:8:in `prebuild'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/tasks/build_step_proxy.rb:22:in `boolean_result'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/tasks/build_step_proxy.rb:7:in `prebuild'

gitlab-hook 1.4.2, Jenkins 2.60, Java 1.8.0_131 (HotSpot).

Cann't trigger a build by merge request hook.

Hi, guys:

I had added http://jenkins_server/gitlab/build_now to Gitlab and add push events and merge request events.

When I push a new code to Gitlab, the hook will trigger my Jenkins job. But when I create a merge request in Gitlab, there had happened nothing.

I don't know what's up. There anyone has the experience?

Jenkins version: 2.7.1
Gitlab version: 10.4.0 & 7.11.4
Gitlab Hook Plugin: 1.4.2

payload can't use dot(.) match

project.namespace had value docker, Jenkinsfile Don't recognize this parameter

node() {
    stage('build') {
        checkout scm
        echo "${repository_name}"
        echo "${project.namespace}"
        
    }
}

trigger specific job but only on commits to a specific branch

I have a project that is made up of a bunch of gitlab repos, but one of the repos is a build repo that has a build script that clones all the necessary repos instead of having jenkins do it.

So the jenkins job only has the build repo specified in the SCM settings. I want to trigger the job if there is a commit to the other repos though, and it seems like this plugin supports that using:

http://your-jenkins-server/gitlab/build_now/project_name

However, I only want the job to trigger if there is a commit to a specific branch. Is this possible?

For example: http://your-jenkins-server/gitlab/build_now/project_name?branch=development

Then the gitlab hook plugin will only trigger the job if the branch from the gitlab payload data matches the branch parameter in the URL.

System hooks not working for latest Gitlab (version 9)

Issue

Gitlab has changed the structure of the webhook messages. The repository url is not detected anymore.

Context

  • Gitlab-Hook plugin version: 1.4.6
  • Gitlab version: 9.3.6
  • Jenkins version: 2.69
  • Job type: Freestyle

Logs & Traces

Problem description

Gitlab has changed the structure of the webhook messages:

Note: Starting from GitLab 8.5:

the repository key is deprecated in favor of the project key
the project.ssh_url key is deprecated in favor of the project.git_ssh_url key
the project.http_url key is deprecated in favor of the project.git_http_url key

https://docs.gitlab.com/ce/user/project/integrations/webhooks.html

webhook url for project in folder

Hello,

For the past few days I've been rebasing my projects. One thing I did was move them from root jenkins and group them in folders.

I had http://site/jenkins/project/projectname as a webhook which stopped working. I've tried all the ways I can think of and found online with no luck. So I thought to try out this plugin.

http://site/jenkins/gitlab/build_now
#Yells: Hook executed successfully but returned HTTP 404 could not found template ''
http://site/jenkins/gitlab/build_now/projectname
#Yells some big html with error 500

undefined method `getQuietPeriod' for nil:NilClass when testing the /build_now/project-name webhook

I added following webhooks for Push and Tag Push Events in gitlab :

http://jenkins.local/gitlab/build_now/my-project

my-project is a Jenkins Pipeline project. When i test the webhooks, i get the following HTTP Response :

NoMethodError at /build_now/my-project
undefined method `getQuietPeriod' for nil:NilClass
file: api.rb location: POST /build_now/:project_name line: 43

with the following stack-trace :

/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/api.rb in POST /build_now/:project_name
 project.scheduleBuild2(project.getQuietPeriod(), cause_builder.with(details), actions_builder.with(project, details))
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb in call
 status, headers, body = @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb in call
 app.call env
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb in call
 status, headers, body = app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/base.rb in call
 result or app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb in call
 status, headers, body = @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/nulllogger.rb in call
 @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/head.rb in call
 status, headers, body = @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/root_action.rb in call
 GitlabWebHook::Api.new.call(env)
file:/var/lib/jenkins/plugins/ruby-runtime/WEB-INF/lib/jruby-rack-1.1.13.1.jar!/rack/handler/servlet.rb in call
 self.class.response.new(@app.call(create_env(servlet_env)))

Include GitLab group name in project name.

When there are repositories in different groups that have the same name, automatic project creation will only create a project for one of the repositories.

Providing an option to include the GitLab group name in the name of the generated projects would solve this problem.

Cant call hook inside a folder with gitlab

Hello, i am having the sabe problem as issue #33

I have job running in

https://jenkins.url.com/jenkins/job/labs/job/m-repo/

And i cant triger it.

Errors i get:

https://jenkins.url.com/jenkins/gitlab/build_now (if called inside gitlab)
Hook executed successfully but returned HTTP 404 could not found template ''

if called in browser:
https://jenkins.url.com/jenkins/gitlab/my-repo

Don't know how to process '/my-repo'
Use one of the following:

if called in browser:
https://jenkins.url.com/jenkins/gitlab/labs/my-repo

Don't know how to process 'labs/my-repo'
Use one of the following:

How can i work around this?

"undefined method `getQuietPeriod' for nil:NilClass" for jobs in folders

Hello. When I create a job just on View (not in folders), webhook build_now/:project_name works successful. But when I create a job in folder via Folders Plugin, I see the message:

<NoMethodError: undefined method `getQuietPeriod' for nil:NilClass>

Backtrace:

/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/api.rb in POST /build_now/:project_name
 project.scheduleBuild2(project.getQuietPeriod(), cause_builder.with(details), actions_builder.with(project, details))
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb in call
 status, headers, body = @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb in call
 app.call env
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb in call
 status, headers, body = app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/base.rb in call
 result or app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb in call
 status, headers, body = @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/nulllogger.rb in call
 @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/head.rb in call
 status, headers, body = @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/root_action.rb in call
 GitlabWebHook::Api.new.call(env)
file:/var/lib/jenkins/plugins/ruby-runtime/WEB-INF/lib/jruby-rack-1.1.13.1.jar!/rack/handler/servlet.rb in call
 self.class.response.new(@app.call(create_env(servlet_env)))
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/crumb_exclusion.rb in process
 chain.doFilter(request, response)

Can't build project anymore

ERROR: private method warn' called for #<Jenkins::Plugin::OpaqueJavaObject:0x63a0991b> (NoMethodError) /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/gitlab_notifier.rb:24:in prebuild'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/tasks/build_step_proxy.rb:8:in prebuild' /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/tasks/build_step_proxy.rb:22:in boolean_result'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/tasks/build_step_proxy.rb:7:in `prebuild'

Jenkins v2.91

Support for Jobs created using the Folders plugin

Currently there are two issues when using the auto job creation feature in combination with jobs that are grouped into folders using the Folders plugin:

  1. Newly created jobs do not have the same parent as the master job
  2. Duplicate jobs are created if the job is grouped in a folder (i.e. not under root). One of them is correct, while the other seems incomplete (description and scm not updated).

No.1 can be solved by simply moving the job under the appropriate parent. This can be accomplished by adding the following line to the with method in the CreateProjectForBranch class right after the project i saved:

branch_project = Java.hudson.model.Items.move(branch_project, copy_from.jenkins_project.parent)

Not sure how to solve No.2, as it might be an issue with the Jenkins API responsible for copying the job. I'll try to come up with a setup that will allow to easily reproduce this issue.

Consider joining forces with gitlab-plugin

I'm one of the maintainers of the Jenkins GitLab plugin (https://wiki.jenkins-ci.org/display/JENKINS/GitLab+Plugin). From what I can tell, that plugin provides the same functionality as this one, plus a few other features. We have a new lead maintainer who is working on a significant redesign of the plugin, including both code cleanup and some new features. At the same time, the core Jenkins community is encouraging people who maintain similar plugins to consider joining forces around a single one, both to reduce user confusion ("Which of these plugins should I use?") and to increase quality of one codebase. This seemed like a good time to suggest that we combine our plugins and work together on supporting GitLab in Jenkins. Thanks!

ruby-runtime plugin issue

Hi Team,

I am using openjdk 11 on my redhat linux machine. My jenkins upgraded from 2.150.1 to 2.204.2 version. After the upgrade, gitlab-hook-plugin is not loading due to ruby-runtime plugin issue. When I am trying to install ruby-runtime plugin 0.12 I am facing the below error.

java.lang.RuntimeExceptipn: unsupported Java version 11
at org.jruby.RubyInstacneConfig.initiGlobalJavaVersion(RubyInstacneConfig.java:1674)
at org.jruby.RubyInstacneConfig.(RubyInstacneConfig.java:1387)

Caused: java.lang.ExceptionInInitializerError

Thanks,
Venkat

Jenkins pipeline and Gitlab webhooks does not work

Hi,
Just for reference I am using the latest Jenkins 2.35 with all the latest Gitlab/Pipeline plugins. My Gitlab (Hosted on our own servers) version is 8.13.2.
I have been using webhooks to start other non-pipeline Jenkins jobs and it works ok. I tried to do the same thing using a pipeline Jenkins job and GitLab will return "Hook executed successfully but returned HTTP 500" and nothing happens on the Jenkins side.
My pipeline job just display a message on the console if the job gets triggered.
This is the link used on my Gitlab webhook: http://MyJenkinsServer/gitlab/build_now/MyPipelineJob
Any help is more than welcome
Down below is my pipeline code.

http://paste.ofcode.org/B9VFa5fHxEqbxKqxLEFAki

"No project references the given repo url" for a merge request

Hello and thank you for the great plugin!

For the regular push-based builds everything works perfectly. For the merge-request based builds I receive all the time the same error:

Apr 04, 2016 1:51:53 PM org.jruby.javasupport.JavaMethod invokeDirectWithExceptionHandling
INFO: matching projects:
    - test-project
Apr 04, 2016 1:51:53 PM org.jruby.javasupport.JavaMethod invokeDirectWithExceptionHandling
WARNING: no project references the given repo url and commit branch

In a global configuration "Create new projects for merge requests" is enabled, of course.

In a project configuration:

  • Repository URL: [email protected]:aleks/test-project.git
  • Branch specifier: origin/master (though I've tried it with master, */master, refs/heads/master, refs/remotes/origin/master and so on)

Gitlab is configured to notify about pushes and merge requests. With push event (to master branch) this job works fine. New projects are not created on a merge request event though jenkins receives the request.

Trigger output (txt)

Versions:

  • GitLab Community Edition 8.5.1 8b7080d
  • Jenkins ver. 1.642.3
  • Gitlab Hook Plugin 1.4.1.1

How to read json payload from gitlab webhook in Jenkins

I have a job using jenkins pipeline to deploy my project. now, I plan to use gitlab-hook-plugin to monitor the submission of projects on gitlab service.
Once a user submits a project change, Jenkins reads the submit parameters and performs other operations according to the type of submission, for example: build and test.
But then there is a problem, how do I read the parameters of the project change , such as submit log, branch, user name and other information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.