-
Hello! I want to use Buildbot to do steps like this:
I don't want to use multiple repositories, in my case it's more convenient to work with multiple directories. I have defined a dynamic trigger class and am using it in my configuration. The trigger fires, but I can't get a list of changed files, so no virtual builders are created. I'm not sure I fully understand the documentation. Maybe I'm trying to get the list of changes in the wrong way. # SPDX-License-Identifier: Unlicense
class DynamicTrigger(steps.Trigger):
def getSchedulersAndProperties(self):
def setVirtualBuilders(changes):
vbuilders = set()
for i in (i['files'] for i in changes if 'files' in i):
dirs = {p[0] for p in (p.split('/') for p in i) if len(p) > 1}
vbuilders.update(dirs)
return list(vbuilders)
changes = self.getProperty('changes') or []
schedulers_and_properties = list()
for scheduler in self.schedulerNames:
for vbuilder in setVirtualBuilders(changes):
props = self.set_properties.copy()
props['virtual_builder_name'] = vbuilder
props['virtual_builder_description'] = str.join(
[vbuilder, "virtual builder"], " ")
props['virtual_builder_tags'] = ['virtual', vbuilder]
schedulers_and_properties.append(
[scheduler, props,
scheduler in self.unimportantSchedulerNames])
return schedulers_and_properties Or maybe my problem is not in this but in getting changes using GitPoller. I can see that the changes displayed in the web interface only include merge commits and do not contain file changes, although they should: Here is also part of my test config file: # SPDX-License-Identifier: Unlicense
...
c['change_source'] = []
c['change_source'].append(changes.GitPoller(
repourl=os.environ.get('BUILDBOT_GIT_REPOURL'),
branches=True, buildPushesWithNoCommits=True,
category='buildah', pollInterval=60
))
c['schedulers'] = []
c['schedulers'].append(schedulers.SingleBranchScheduler(
name='buildah-change', reason='Modifying repository files',
change_filter=util.ChangeFilter(
category='buildah',
branch='production'
),
treeStableTimer=3,
builderNames=['images']
))
c['schedulers'].append(schedulers.Triggerable(
name="image", reason='Modifying directory files',
builderNames=['image']
))
imagesFactory = util.BuildFactory()
imagesFactory.addSteps([
steps.Git(
name='pull',
description='Pull repository',
repourl=util.Property('repository'),
branch=util.Property('branch'),
mode='incremental',
clobberOnFailure=True
),
DynamicTrigger(
name='trigger',
schedulerNames=['image'],
waitForFinish=True,
updateSourceStamp=True)
])
imageFactory = util.BuildFactory()
imageFactory.addSteps([
steps.ShellCommand(
command=["ls", "-l"]
)
])
c['builders'] = []
c['builders'].append(util.BuilderConfig(
name='images', factory=imagesFactory,
workernames=[os.environ.get('BUILDBOT_WORKERNAME')]
))
c['builders'].append(util.BuilderConfig(
name='image', factory=imageFactory,
collapseRequests=False,
workernames=[os.environ.get('BUILDBOT_WORKERNAME')]
))
... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I have two updates. First, I did have problem with the GitPoller configuration. I didn't found this in the Buildbot documentation, but when When I set There is logic in this behavior, but, unfortunately, it is not obvious at first glance. Second, I still have a problem getting a list of changed files on build steps. I found a solution here that uses Database API, it actually works, but I think there is a simpler solution. If I try to use I see that it is possible to get the list of changes, but for some reason it only contains the last commit. I think I am doing something wrong. How can I get list of changes containing all changes on the branch? |
Beta Was this translation helpful? Give feedback.
Since I'm now using the DATA API to get all changes for current build, my dynamic trigger now looks like this: