How to output stdout logging in a .log file in buildbot

71 Views Asked by At
from buildbot.plugins import util, steps, schedulers, worker, changes
from buildbot.steps import source, shell
from buildbot.changes.filter import ChangeFilter
from buildbot.process import factory
f = factory.BuildFactory()
#steps for bld_dir_noinstall factory - NOTE these steps are simplified to run example project LY will need to update this to handle more than one argument

 

#Step 1: Start log

 

log = steps.ShellCommand(name= 'log', command = ['cat > /tmp/log.txt','bld', 'echo hello world >> log.txt'], haltOnFailure=True)

this is the new master.cfg it runs but nothing is outputted to /tmp 

#Step 2: Print the start date
start = steps.ShellCommand(name='start', command=['echo', 'Start `date`'], haltOnFailure=True)
#Step 3: clear everything
clean = steps.ShellCommand(name='clean', command=['echo','Cleaning example project', ';', 'rm', '-r', '-f', '*'])
#Step 4: git clone
git = steps.Git(repourl='example server', mode='incremental', haltOnFailure=True)
#Step 5: cmake
cmake = steps.ShellCommand(name='cmake', command=['cmake', '-S', '.', '-B', 'bld'], haltOnFailure=True)
#Step 6: make
make = steps.ShellCommand(name='make', command=['make', '-C', 'bld', '-j7'], haltOnFailure=True)
#Step 7: make packages
makePackage = steps.ShellCommand(name='makePackage', command=['make', 'package', '-C', 'bld', '-j7'], haltOnFailure=True)
#Step 8: move package to /data/build/dir/dir2/dir3
movePackage = steps.ShellCommand( name='movePackage', command=['sh', '-c', 'mv bld/*.rpm  /data/build/dir/dir2/dir3'], workdir='build', haltOnFailure=True)
#Step 9: Print the end date
end = steps.ShellCommand(name='end', command=['echo', 'Finish `date`'])

 

 

#problem with factory for each bash function: will have to figure out how to change the git step for each one to grab the correct project

 

bld_dir_noinstall_factory = util.BuildFactory()
bld_dir_noinstall_factory.addStep(log)
log = f.addStep(steps.ShellCommand(command=["make", "test"],
        logfiles={
                "triallog": {
                        "filename": "_trial_temp/test.log",
                         "follow": True
                 }

 

        }))

 


bld_dir_noinstall_factory.addStep(start)
bld_dir_noinstall_factory.addStep(clean)
bld_dir_noinstall_factory.addStep(git)
bld_dir_noinstall_factory.addStep(cmake)
bld_dir_noinstall_factory.addStep(make)
bld_dir_noinstall_factory.addStep(makePackage)
bld_dir_noinstall_factory.addStep(movePackage)
bld_dir_noinstall_factory.addStep(end)

 

BuildmasterConfig = c = {}

 

worker = worker.Worker('example project', 'pass')
c['workers'] = [worker]

 

c['builders'] = []
c['builders'].append(util.BuilderConfig(name='example project', workernames=['example project'], factory=bld_dir_noinstall_factory))

 

example scheduler= schedulers.SingleBranchScheduler(name='example scheduler', change_filter=util.ChangeFilter(branch='master', project='example project'), treeStableTimer=10, builderNames=['LCrypt'])
c['schedulers'] = [example scheduler]

 

example pollar= changes.GitPoller(repourl='example git server', pollinterval=15, branch='master', project='example pollar')
commandLine = changes.PBChangeSource()
c['change_source'] = [example pollar, commandLine]

 

c['protocols'] = {"pb": {"port": example port"}}

This is the master.cfg made in buildbot however it is not outputting stdout to .log file one that is different from the twistd.log. As I have made a function I am confused on what to do next to get it to write stdout to a file and put it in the /tmp directory.

I have tried to edit the master.cfg with what I have posted above nothing outputting into the/tmp directory.

0

There are 0 best solutions below