README.rst

Taskotron Job Trigger

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

Installation

Install the rpm dependencies on the system (only works on Fedora for now):

$ dnf install fedmsg-hub git koji

Parts of the trigger do need to be installed on the local system:

$ python setup.py install

Updating Production Logging Configuration

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"],
},

Running the Trigger

Once the fedmsg component has been installed, run the following command in the working directory with triggerjob.py:

$ fedmsg-hub

Setting Up a Dev Environment

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 --ignore-installed -r requirements.txt

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 and git_cache_dir to a path where you have write access
  • rules_template to a file with your trigger rules, you can use conf/trigger_rules.yml.example as a starting point
  • critpath_filepath to a critpath definition, you can use docker_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

Running the test suite

From inside the virtualenv run:

$ py.test