[
https://issues.jenkins-ci.org/browse/JENKINS-10147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=162928#comment-162928
]
Julien-Pierre Avérous commented on JENKINS-10147:
-------------------------------------------------
I fixed the problem with a very-temporary hack in the code, waiting for an
official patch.
I have added this code :
{code:borderStyle=solid}
SCM scm = project.getScm();
if (scm != null)
{
// Check that we don't have change in SCM
PollingResult res = project.poll(LogTaskListener.NULL);
if (res == NO_CHANGES)
{
// Check that we have a sucessfull build
Run success = project.getLastSuccessfulBuild();
if (success != null)
{
listener.getLogger().println("Skipping " +
HyperlinkNote.encodeTo('/'+ project.getUrl(), project.getFullDisplayName()) +
". No change happen since last build.");
continue;
}
}
}
{code}
just before
{code:borderStyle=solid}
futures.add(schedule(build, project, list));
{code}
in 'perform' method of 'BuildTriggerConfig.java'
and just before
{code:borderStyle=solid}
futures.put(project, schedule(build, project, list));
{code}
in 'perform2' method of 'BuildTriggerConfig.java'
This import should be added too in this file :
{code:borderStyle=solid}
import hudson.console.HyperlinkNote;
import hudson.scm.SCM;
import hudson.scm.PollingResult;
import hudson.util.LogTaskListener;
import hudson.model.Run;
import static hudson.scm.PollingResult.*;
{code}
This seem to work well for me.
Caveats :
- The line 'if (futures.isEmpty())' condition in TriggerBuilder.java print a
bad log in the console when all project in the trigger list doesn't need to be
rebuild. Not a problem, but not beautiful.
- If the configuration of a project change but not the SCM, the build is not
re-triggered.
- Probably some others things.
> Add 'poll SCM' option to build step
> -----------------------------------
>
> Key: JENKINS-10147
> URL: https://issues.jenkins-ci.org/browse/JENKINS-10147
> Project: Jenkins
> Issue Type: New Feature
> Components: parameterized-trigger
> Reporter: G. Ann Campbell
> Assignee: huybrechts
> Priority: Minor
>
> It would be nice, in at least the 'build step' part of the
> parameterized-trigger plugin, to have the option to build conditionally based
> on SCM polling.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira