elvanja / jenkins-gitlab-hook-plugin

Enables Gitlab web hooks to be used to trigger SMC polling on Gitlab projects
142 stars 81 forks source link

Schedule build only if project polling detects changes #51

Closed javiplx closed 9 years ago

javiplx commented 9 years ago

This avoids to build jobs that should be prevented by advanced git plugin configuration, such as directory exclusion.

elvanja commented 9 years ago

I've refactored this a bit, moved has_changes? to project and added specs.

elvanja commented 9 years ago

@javiplx I had to revert related changes due to an issue with determining if there were changes. Namely, if previous build was for a feature/x branch, and the new commit is for master branch, it will not trigger the build, and it should. See hudson.model.AbstractProject.poll and jenkins.model.lazy.LazyBuildMixIn.getLastBuild for details.

I've created a separate branch with related code: https://github.com/elvanja/jenkins-gitlab-hook-plugin/blob/feature/do_not_trigger_when_no_scm_changes/models/values/project.rb#L78.

Unless we can think of a reasonable solution for this, I am afraid I'll have to leave this one out.

Any ideas?

javiplx commented 9 years ago

That sound very strange to me. If that is the case it would be a bug of the git plugin, and should affect other plugins, in particular the github and the other gitlab plugin, from where I take the poll method. We don't really have projects with multiple branches, except those that build tags (using $BRANCH_TO_BUILD), and they seem to work with no problem, although tags are a bit different than branches. In any case, I'll try to setup a project to test what you say.