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

Trigger only autogenerated jobs, not all the jobs for given git url

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Critical Critical
    • gitlab-hook-plugin
    • None

      Currently gitlab-hook-plugin searches all the jobs that match given repository url.

      In fact, I use multijob configuration like the following:

      MainJob <-- uses git configuration so gitlab-hook-plugin can find & clone & start it
        * Phase 1: compile job <-- uses git to fetch project sources
        * Phase 2: deploy
        * Phase 3: fast tests <-- uses git to fetch tests
      ...
      

      Current gitlab-hook-plugin triggers all the jobs, not just the main one.

      In my installation I've modified plugins\gitlab-hook\WEB-INF\classes\models\use_cases\process_commit.rb }} as follows (added {{ && (project.description.match /#{settings.description}/)) so it triggers only jobs with autogenerated description:

          def get_projects_to_process(details)
            projects = @get_jenkins_projects.matching_uri(details)
            if projects.any?
              if settings.automatic_project_creation?
                projects.select! do |project|
                  project.matches?(details, details.branch, true) && (project.description.match /#{settings.description}/)
                end
                projects << @create_project_for_branch.with(details) if projects.empty?
      

      However, it could make sense to use another approach: get the job by name (hook knows naming convention, so it can get the job) check if that matches. In case the job does not match fallback to the current implementation.

            javiplx Javier Palacios
            vladimirsitnikov Vladimir Sitnikov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: