Skip to content

err plugin to interact with Jenkins CI (Python3 compatible port)

License

Notifications You must be signed in to change notification settings

Djiit/err-jenkins

 
 

Repository files navigation

err-jenkins - Jenkins plugin for Err

Build Status Coverage Status

Err-jenkins is a plugin for Err that allows you to interact with Jenkins, a continuous integration tool.

Features

  • Support Jenkins 2.x!
  • Search / List available jobs.
  • List parameters for a given job.
  • Create job (workflow-plugin / pipeline standard and multibranch jobs only)
  • Enable, Disabled and Delete job.
  • Create node (JNLP launcher only).
  • Enable, Disabled and Delete node.
  • Build jobs with or without parameters.
  • Webhook support! Receive REST calls on build success/failure
  • Tested with freestyle and pipeline (workflow plugin) jobs.
  • Support AUTOINSTALL_DEPS thanks to the requirements.txt file.

Have an idea ? Open an issue or send me a Pull Request.

Usage

Requirements

This plugin is tested against Python 2.7+ and 3.3+. It only depends on the python-jenkins and validators packages:

pip install python-jenkins validators

Installation

As admin of an err chatbot, send the following command over XMPP:

!repos install https://github.com/Djiit/err-jenkins.git

Commands

Check out the examples !

Use !help JenkinsBot to see the available commands and their explanation.

Configuration

You can set some default configuration values in your Errbot's config.py:

# Main configuration
JENKINS_URL = 'http://jenkins.example.com'  # Must begins with 'http' or 'https'.
JENKINS_USERNAME = 'myuser'  # Make sure Jenkins ACL is configured.
JENKINS_PASSWORD = 'mypassword'  # Use a password or token.

# Webhooks configuration
JENKINS_RECEIVE_NOTIFICATION = True  # If True, this plugin will accept HTTP POST from Jenkins (see configuration below).
JENKINS_CHATROOMS_NOTIFICATION = ()  # Tuples of chatroom names where Err should post messages from Webhooks. If left empty, all chatrooms will be spammed.

If left undefined, you will have to send configuration commands through chat message to this plugins as in :

!plugin config JenkinsBot {'URL': 'http://jenkins.example.com', 'USERNAME': 'myuser', 'PASSWORD': 'mypassword', 'RECEIVE_NOTIFICATION': True, 'CHATROOMS_NOTIFICATION': ()}

Webhooks setup

To be able to receive messages based on build success and/or failure :

  1. Set JENKINS_RECEIVE_NOTIFICATION (in config.py) or RECEIVE_NOTIFICATION' (through chat message) configuration option to True.
  2. Install and enable the Jenkins Notification Plugin
  3. Configure your project's notifications as in :

Build Status

Note : if you are using the Pipeline DSL, use this snippet instead :

properties(properties:[[
    $class: 'HudsonNotificationProperty',
    endpoints: [[
      event: 'all', // 'all', 'completed', 'finalized' or 'started'
      format: 'JSON',
      loglines: 0,
      protocol: 'HTTP',
      timeout: 30000,
      url: 'http://errbot.example.com/jenkins/notification'
    ]]
  ]])

Credits

This plugin is based on the original work by benvd.

About

err plugin to interact with Jenkins CI (Python3 compatible port)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%