Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-27101

Undefined method isOlderThan on automatic project creation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: gitlab-hook-plugin
    • Labels:
      None
    • Environment:
      Jenkins version: 1.599
    • Similar Issues:

      Description

      Hi,

      I tried to figure out how to setup the automatic project creation, but until now without success. Here are the steps what I did:

      created a new project called 'template'

      • parametrized build with string parameter BRANCH_TO_BUILD (default = master)
      • parametrized build with string parameter REPOSITORY_URL
      • Source Code Management --> Branch specifier: origin/${BRANCH_TO_BUILD}
      • Source Code Management --> Repository URL: ${REPOSITORY_URL}

      jenkins settings

      • enabled Automatic project creation
      • added the name 'template' to Last resort template

      Then I added the build_now hook to a gitlab project web hook and clicked on test hook. When nothing occurred I had a look into the jenkins logs and found the following (I modified the gitlab payload part):

      gitlab web hook triggered for

      • repo url: git@example.com:diaspora/diaspora.git
      • branch: master
      • with payload:
        {
        "before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
        "after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
        "ref": "refs/heads/master",
        "user_id": 4,
        "user_name": "John Smith",
        "project_id": 15,
        "repository": { "name": "Diaspora", "url": "git@example.com:diaspora/diaspora.git", "description": "", "homepage": "http://example.com/diaspora/diaspora", "private": true }

        ,
        "commits": [

        Unknown macro: { "id"}

        ,

        Unknown macro: { "id"}

        ],
        "total_commits_count": 2
        }
        Feb 24, 2015 1:51:17 PM INFO org.jruby.javasupport.JavaMethod invokeDirectWithExceptionHandling
        matching projects:
        Feb 24, 2015 1:25:38 PM SEVERE org.jruby.javasupport.JavaMethod invokeDirectWithExceptionHandling
        undefined method `isOlderThan' for true:TrueClass
        org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `isOlderThan' for true:TrueClass
        at RUBY.with(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/models/services/build_scm.rb:21)
        at RUBY.from_template(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/models/use_cases/create_project_for_branch.rb:37)
        at RUBY.get_projects_to_process(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/models/use_cases/process_commit.rb:53)
        at RUBY.with(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/models/use_cases/process_commit.rb:15)
        at RUBY.process_projects(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/models/api.rb:45)
        at RUBY.POST /build_now(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/models/api.rb:30)
        at org.jruby.RubyMethod.call(org/jruby/RubyMethod.java:118)
        at RUBY.compile!(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265)
        at org.jruby.RubyProc.call(org/jruby/RubyProc.java:249)
        at RUBY.route!(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835)
        at RUBY.route_eval(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:851)
        at RUBY.route!(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835)
        at RUBY.process_route(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:872)
        at org.jruby.RubyKernel.catch(org/jruby/RubyKernel.java:1174)
        at RUBY.process_route(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:870)
        at RUBY.route!(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:834)
        at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1613)
        at RUBY.route!(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:833)
        at RUBY.dispatch!(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:936)
        at RUBY.call!(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:769)
        at RUBY.invoke(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:921)
        at org.jruby.RubyKernel.catch(org/jruby/RubyKernel.java:1174)
        at RUBY.invoke(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:921)
        at RUBY.call!(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:769)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:755)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/nulllogger.rb:9)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/head.rb:9)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/showexceptions.rb:21)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:99)
        at RUBY.call(/Users/Shared/Jenkins/Home/plugins/gitlab-hook/WEB-INF/classes/models/root_action.rb:18)
        at RUBY.call(file:/Users/Shared/Jenkins/Home/plugins/ruby-runtime/WEB-INF/lib/jruby-rack-1.1.13.1.jar!/rack/handler/servlet.rb:22)

      Am I doing something wrong or is this a bug?

      Thanks in advance
      Christian

        Attachments

          Activity

          Hide
          javiplx Javier Palacios added a comment -

          Release 1.2.x had some bugs related to automatic project creation which get solved on 1.3.0, although the one I see on your logs is new to me. Try using the 1.3.1-SNAPSHOT version, because the release 1.3.0 will not work unless you let anonymous user to create project.

          Although I don't really believe is related to that, please add also information about the version of git plugin you are using,

          Show
          javiplx Javier Palacios added a comment - Release 1.2.x had some bugs related to automatic project creation which get solved on 1.3.0, although the one I see on your logs is new to me. Try using the 1.3.1-SNAPSHOT version , because the release 1.3.0 will not work unless you let anonymous user to create project. Although I don't really believe is related to that, please add also information about the version of git plugin you are using,
          Hide
          chrisdo82 Christian Dornbusch added a comment -

          I get the same errors with the 1.3.1-Snapshot version.

          git plugin: v2.3.5

          Show
          chrisdo82 Christian Dornbusch added a comment - I get the same errors with the 1.3.1-Snapshot version. git plugin: v2.3.5
          Hide
          javiplx Javier Palacios added a comment -

          I was afraid of that. It's probably not hard to fix, but I might take a bit to get time for that. In the meantime, you can find models/services/build_scm.rb under your jenkins plugins directory and comment lines 21,22,23 & 25, leaving only

              build_scm(scm_data)
          

          although I guess the problem could be in the call to with method of BuildScm, and if I'm right it will just move the error to another place.

          Show
          javiplx Javier Palacios added a comment - I was afraid of that. It's probably not hard to fix, but I might take a bit to get time for that. In the meantime, you can find models/services/build_scm.rb under your jenkins plugins directory and comment lines 21,22,23 & 25, leaving only build_scm(scm_data) although I guess the problem could be in the call to with method of BuildScm, and if I'm right it will just move the error to another place.
          Hide
          javiplx Javier Palacios added a comment -

          I've fixed the with call on this package. But the change is quite simple, so you can even try editing the exploded files.
          If it works, I'll release it as 1.3.1.

          Show
          javiplx Javier Palacios added a comment - I've fixed the with call on this package . But the change is quite simple , so you can even try editing the exploded files. If it works, I'll release it as 1.3.1.
          Hide
          chrisdo82 Christian Dornbusch added a comment -

          Yes it works Thank you so much!!!

          The only thing I noticed is that the string parameter for the git branch didn't get substituted.

          Show
          chrisdo82 Christian Dornbusch added a comment - Yes it works Thank you so much!!! The only thing I noticed is that the string parameter for the git branch didn't get substituted.
          Hide
          javiplx Javier Palacios added a comment -

          I'm not sure if I understand you, but If I'm right it is maybe a documentation problem. From what I understand in your report, you are actually creating a project from a template, and in that case, the only action taken when copying the template is to replace the repository url and enable the project because template could be disabled). It seems that you are expecting that some variables defined on the template get replaced with some values from payload.
          It looks like REPOSITORY_URL is actually replaced, but it isn't. Whatever the template has configured as git url is discarded and filled from payload (actually, I use templates with empty git url). And accordingly, the branch specification is kept exactly as in template. And your final job has one useless parameter (probably two).

          If you remove the two parameters of your template and set the branch specifier to origin/master, you'll probably get what you expect. But take into account that templating only acts when the push is for an unknown repo. Once you get the template realized, you need to enable "classic" automatic branch creation to get extra instances for that same project when other branches are pushed.

          Show
          javiplx Javier Palacios added a comment - I'm not sure if I understand you, but If I'm right it is maybe a documentation problem. From what I understand in your report, you are actually creating a project from a template, and in that case, the only action taken when copying the template is to replace the repository url and enable the project because template could be disabled). It seems that you are expecting that some variables defined on the template get replaced with some values from payload. It looks like REPOSITORY_URL is actually replaced, but it isn't. Whatever the template has configured as git url is discarded and filled from payload (actually, I use templates with empty git url). And accordingly, the branch specification is kept exactly as in template. And your final job has one useless parameter (probably two). If you remove the two parameters of your template and set the branch specifier to origin/master, you'll probably get what you expect. But take into account that templating only acts when the push is for an unknown repo. Once you get the template realized, you need to enable "classic" automatic branch creation to get extra instances for that same project when other branches are pushed.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Javier Palacios
          Path:
          models/services/build_scm.rb
          spec/services/build_scm_spec.rb
          http://jenkins-ci.org/commit/gitlab-hook-plugin/e1519d1bc6da511b9a69cb4cef04103e64e65dd7
          Log:
          JENKINS-27101: set right prototype for BuildScm.with

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Javier Palacios Path: models/services/build_scm.rb spec/services/build_scm_spec.rb http://jenkins-ci.org/commit/gitlab-hook-plugin/e1519d1bc6da511b9a69cb4cef04103e64e65dd7 Log: JENKINS-27101 : set right prototype for BuildScm.with

            People

            • Assignee:
              javiplx Javier Palacios
              Reporter:
              chrisdo82 Christian Dornbusch
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: