[Buildbot-devel] Exec debuild shell command only if debian/changelog was commited at subversion

J. Félix Ontañón fontanon at emergya.es
Wed Mar 12 09:57:12 UTC 2008


El Wed, 12 Mar 2008 08:37:31 +0100
"A.T.Hofkamp" <a.t.hofkamp at tue.nl> escribió:

> J. Félix Ontañón wrote:
> > I've a lot of source-packages in a subversion, and i want my
> > buildslave to, after any commit, do svn-export and make debuild
> > only of the packages that has been commited their debian/changelog
> > file.
> 
> In general, it is considered better not to have special build magic
> in buildbot. Instead consider such scripts as part of your source
> code, so you can maintain (and use it!) away from buildbot too.
> 
> In your case, you may want to first start writing one or more scripts
> that does what you want from the command line in a working copy.
> 
> Once you have that, you can move it to buildbot.

First, thanks for your help, Albert.

I understand, maybe it's better to code scripts that do the checks and
only build if changelog has been changed.

But my idea behind is:

 * A SVNPoller checks svn changes every 30min (thats easy)
 * There is one Builder (buildbot builder) for each source-package in
my svn (easy too).
 * After a svn polling, a Scheduler it's dinamically created to only
execute the Builder of the source-packages with debian/changelog
modified (hard ... isnt?)
 * Final Effect: In the Waterfall you'll only see the results of the
launched Builders. (wow !)

It's possible?

> 
>  > It's there any helping documentation?, any ideas?
> 
> Maybe compare the MD5 hash of the changelog with the MD5 hashes of
> the already built packages?

I did that implementation to check if the debian/changelog was commited
to svn and exec something.

=============================================================
from twisted.python import log
from buildbot.steps import shell
from buildbot.process.buildstep import RemoteShellCommand

class ExecIfChangelogModified(shell.ShellCommand):
  def start(self):
    # Substitute build properties
    command = self._interpolateProperties(self.command)

    # fail assert if is not of correct type
    assert isinstance(command, (list, tuple, str))

    # Get changed file list from the build which invoked this step
    files = self.build.allFiles()

    # We have created the final command string
    # so we can fill out the arguments for a RemoteShellCommand
    # using our new command string
    kwargs = self.remote_kwargs
    kwargs['logfiles'] = self.logfiles

    changelog_modified = False
    for file in files:
            if kwargs['changelog'] in file:
                changelog_modified = True
                break

    if changelog_modified:
        kwargs['command'] = command
    else:
        kwargs['command'] = ":"
        self.command = "None to build"
        # BuildStepStatus log
        self.step_status.setColor('red')
        self.step_status.setText(['No', 'need', 'to', 'build'])
        # Log the changed files to twistd.log
        log.msg("No build requiered: %s" % files)

    # Create the RemoteShellCommand and start it
    cmd = RemoteShellCommand(**kwargs)
    self.setupEnvironment(cmd)
    self.checkForOldSlaveAndLogfiles()
    self.startCommand(cmd)
=============================================================

In master.cfg i did:

=============================================================
f0 = factory.BuildFactory()
f0.addStep(source.SVN(svnurl="file:///var/svn/apps/grubaker/trunk",
	mode="export))
f0.addStep(ExecIfChangelogModified, command=["debuild", "-uc", "-us"])

b0 = {'name' : "apps-grubaker",
      'slavename' : "appsbuilder",
      'builddir' : "apps/grubaker",
      'factory': f0,

c['builders'] = [b0, b1, b2] <----- One builder for each source-package
=============================================================

But it's a real pity to have to exec every Builder in each svn-polling.

> Sincerely,
> Albert

Thanks again for your help.
 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel




More information about the devel mailing list