This is very simple code that listens for fedmsg messages of specific types and triggers jobs in taskotron in buildbot as needed.
Project page: https://pagure.io/taskotron/taskotron-trigger
Install the rpm dependencies on the system (only works on Fedora for now):
$ sudo dnf install fedmsg-hub git koji
Then install the trigger. Please note that the following installation is suitable just for containers or similar systems, because it copies files directly to your system directories. It is much better to install an RPM version of trigger (available for Fedora). If you want to set up a development environment, look into that particular section (below) instead. If you really intend to install the files into system dirs, do:
$ sudo python setup.py install
In /etc/fedmsg.d/logging.py
, add the following handler:
filelog={ "class": "logging.handlers.RotatingFileHandler", "formatter": "bare", "level": "INFO", "filename": "/var/log/fedmsg/taskotron-trigger.log", "mode": "a", }
Then replace the console handler with the filelog handler for the fedmsg logger so that log messages are sent to a separate file instead of to the console:
fedmsg={ "level": "INFO", "propagate": False, - "handlers": ["console"], + "handlers": ["filelog"], },
Once the fedmsg component has been installed, run the following command in the working directory with triggerjob.py:
$ fedmsg-hub
Install the RPM dependencies mentioned in the Installation section. Then also install the following:
$ sudo dnf install python2-virtualenv python-pip
Create a virtualenv for the trigger, including system site-packages to make sure that we get koji:
$ virtualenv --system-site-packages env_trigger/ $ source env_trigger/bin/activate
Install requirements:
$ pip install -r requirements.txt
If you encounter any installation issues, it's possible that you don't have
gcc
and necessary C development headers installed to compile C extensions
from PyPI. Either install those based on the error messages, or install
the necessary packages directly to your system. See requirements.txt
to
learn how.
Install taskotron-trigger in a development mode:
$ pip install -e .
Create a local configuration file:
$ cp conf/trigger.cfg.example conf/trigger.cfg
Edit conf/trigger.cfg
and set:
job_logging = True
joblog_file
andgit_cache_dir
to a path where you have write accessrules_template
to a file with your trigger rules, you can useconf/trigger_rules.yml.example
as a starting pointcritpath_filepath
to a critpath definition, you can usedocker_data/critpath_whitelist.example
as a starting point
Once this is all done, you can run fedmsg-hub and it will pick up the local configuration without modifying the local system:
$ fedmsg-hub
If you use the default trigger rules, you should see similar messages to confirm they have been enabled:
[ fedmsg INFO] enabled by config - jobtriggers.dist_git_commit_msg:DistGitCommitJobConsumer [ fedmsg INFO] No backlog handling. status: None, url: None [ fedmsg INFO] enabled by config - jobtriggers.koji_build_msg:KojiBuildCompletedJobConsumer [ fedmsg INFO] No backlog handling. status: None, url: None [ fedmsg INFO] enabled by config - jobtriggers.compose_complete_msg:ComposeCompletedJobConsumer [ fedmsg INFO] No backlog handling. status: None, url: None [ fedmsg INFO] enabled by config - jobtriggers.koji_tag_msg:KojiTagChangedJobConsumer [ fedmsg INFO] No backlog handling. status: None, url: None
After a short time of waiting you should see new events being detected, e.g.:
[ fedmsg INFO] triggering rpmlint for kig-16.12.2-1.fc26 on x86_64 [ fedmsg INFO] StreamRunner received: item: kig-16.12.2-1.fc26 item_type: koji_build taskname: rpmlint arch: x86_64
From inside the virtualenv run:
$ py.test