Details
-
Type:
New Feature
-
Status: Closed (View Workflow)
-
Priority:
Critical
-
Resolution: Fixed
-
Component/s: gitlab-hook-plugin
-
Labels:None
-
Similar Issues:
Description
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.
Attachments
Issue Links
- is related to
-
JENKINS-29283 Allow cloning job trees when creating job via gitlab web hook
-
- Closed
-
-
JENKINS-29318 Support deleting multiple jobs on branch delete
-
- Open
-
I've no experience with multijob projects, but the plugin does search projects that match the repository url, so if your phase 2 & 3 are triggered, it is because they also clone your git repository.
Your suggestion is not bad, but it breaks everything else, as every job created manually will stop building on pushes. A configuration item could be added to enable this "only autocreated" behaviour, but I would like to understand your use case before attempting it.
Regarding your second suggestion, if I understand it well, has the same problem of your current modification, and forces to name the project as the repository, and although it's probably happening with most cases, nothing guarantees that.