[Buildbot-devel] required fields forcing a build

Harry Borkhuis harry at aeteurope.nl
Tue Dec 13 08:27:36 UTC 2011


Pierre,

In your proposal you use the method addBuildsetForLatest, but this method
does not have the parameter 'revision' which probably is by design
('forLatest'). So you cannot force a specific revision.

Only in case of changeids a specific revision can be specified. But I do not
understand how to pass changeids to a force build. Where do the changeids
come from?

Harry

-----Original Message-----
From: Pierre Tardy [mailto:tardyp at gmail.com] 
Sent: Monday, December 12, 2011 9:42 PM
To: Harry Borkhuis
Cc: buildbot-devel at lists.sourceforge.net
Subject: Re: [Buildbot-devel] required fields forcing a build

> Looking at the implementation of the Force-Scheduler I expect some
> complication when using multi-repositories.
> The force-scheduler partly re-implements the BaseScheduler.
> addBuildsetForChanges(). The only difference is that there are no changes
> created. Implementing the multi-repo functionality would require to change
> BaseScheduler and Force-Scheduler in almost the same way.

I think you are talking about the following code:

https://github.com/buildbot/buildbot/blob/master/master/buildbot/schedulers/
forcesched.py#L287
        d = master.db.sourcestamps.addSourceStamp(branch=branch,
                revision=revision, project=project,
repository=repository,changeids=changeids)
        def got_ssid(ssid):
            return
self.addBuildsetForSourceStamp(builderNames=[builder_name],
                                      ssid=ssid, reason=r,
                                      properties=real_properties)
        d.addCallback(got_ssid)

We cannot use addBuildsetForChanges here, because changeids might be
empty, the project and repository for  the source stamp would in that
case be unknown. In that forcedsched case, those are passed as a
forced build parameter by user or config, and not got from change.

I agree that this is not perfect, and changes could be passed that are
not related to this project and repository, and no check are done to
ensure this is not the case.

If you want forcesched to use base, you would write something like
this (this pass the unit tests)

diff --git a/master/buildbot/schedulers/base.py
b/master/buildbot/schedulers/base.py
index 06b74cd..2ea04ff 100644
--- a/master/buildbot/schedulers/base.py
+++ b/master/buildbot/schedulers/base.py
@@ -260,6 +260,7 @@ class BaseScheduler(service.MultiService,
ComparableMixin):

     def addBuildsetForLatest(self, reason='', external_idstring=None,
                         branch=None, repository='', project='',
+                        revision = None,
                         builderNames=None, properties=None):
         """
         Add a buildset for the 'latest' source in the given branch,
@@ -284,7 +285,7 @@ class BaseScheduler(service.MultiService,
ComparableMixin):
         @returns: (buildset ID, buildrequest IDs) via Deferred
         """
         d = self.master.db.sourcestamps.addSourceStamp(
-                branch=branch, revision=None, repository=repository,
+                branch=branch, revision=revision, repository=repository,
                 project=project)
         d.addCallback(self.addBuildsetForSourceStamp, reason=reason,
                                 external_idstring=external_idstring,
diff --git a/master/buildbot/schedulers/forcesched.py
b/master/buildbot/schedulers/forcesched.py
index 477a774..6d1d3a0 100644
--- a/master/buildbot/schedulers/forcesched.py
+++ b/master/buildbot/schedulers/forcesched.py
@@ -284,11 +284,15 @@ class ForceScheduler(base.BaseScheduler):
         r = ("The web-page 'force build' button was pressed by '%s': %s\n"
              % (owner, reason))

-        d = master.db.sourcestamps.addSourceStamp(branch=branch,
-                revision=revision, project=project,
repository=repository,changeids=changeids)
-        def got_ssid(ssid):
-            return
self.addBuildsetForSourceStamp(builderNames=[builder_name],
-                                      ssid=ssid, reason=r,
-                                      properties=real_properties)
-        d.addCallback(got_ssid)
-        return d
+        if changeids:
+            return self.addBuildsetForChanges(reason=r,
changeids=changeids,
+                                              builderNames=[builder_name],
+                                              properties=real_properties)
+        else:
+            return self.addBuildsetForLatest(reason=r,
+                                             builderNames=[builder_name],
+                                             properties=real_properties,
+                                             branch=branch,
+                                             revision=revision,
+                                             project=project,
+                                             repository=repository)

regards,
Pierre






More information about the devel mailing list