Giter VIP home page Giter VIP logo

jenot's Introduction

JeNot - Jenkins Notifications

codecov tests

NOTE: under construction, buggy, and not production-ready

What

A tool to notify you when Jenkins builds are done.

Why

Jenkins has tons of various plugins and integrations to send notifications anywhere, from emails to teapots. Yet all of these require that the Job must contain some sendNotification(receiver) code.

Meanwhile, there are cases where only you personally are interested in said notification. Perhaps you are an admin waiting for some build to release the node, so you can reboot it. Or maybe you are an eager tester waiting for someone else's build to finish. Especially if your Jenkins is not a CI but simple Automation server.

In that case, you have to monitor Jenkins jobs from outside. Enter jenot.

How

By using your username and API token to bang on Jenkins REST API and hope that at some point it responds with {"finished": true}. In that case - cue fanfare, Zenity, telegram-send et. cetera.


Developing

  • git clone
  • python -m venv venv && . venv/bin/activate
  • pip install -e .[dev,test]
  • debug in VS Code:
// launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "jenot.qt",
            "type": "python",
            "request": "launch",
            "module": "jenot.qt"
        }
    ]
}

Testing

  • folder test/unit contains unit tests that can should be runnable on their own
  • folder test/integration contains system tests that will require Jenkins instance
  • docker-compose up -d
  • pytest

In VS Code, command:python.runtests should work after applying these settings:

// settings.json
{
    "python.testing.pytestEnabled": true,
    "python.testing.pytestArgs": [
        "test"
    ],
    "python.testing.unittestEnabled": false,
}

To run by hotkey (default is Alt+A), use this task:

// tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "pytest",
            "command": "${command:testing.runAll}",
            "problemMatcher": [],
            "group": {
                "kind": "test",
                "isDefault": true
            }
        }
    ]
}

Installing

  • pip install https://github.com/Artalus/jenot/archive/refs/heads/master.zip
  • TODO: provide executables from pyinstaller or something

jenot's People

Contributors

artalus avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

jenot's Issues

crashes on linux when launched from xfce menu

Crashes after adding a new watch. Apparently, generates core dump somewhere inside qthread?

journalctl output
авг 19 13:57:17 dssl audit[186345]: ANOM_ABEND auid=1000 uid=1000 gid=1000 ses=2 pid=186345 comm="QThread" exe="/usr/bin/python3.9" sig=6 res=1
авг 19 13:57:17 dssl kernel: audit: type=1701 audit(1629370637.181:1086): auid=1000 uid=1000 gid=1000 ses=2 pid=186345 comm="QThread" exe="/usr/bin/python3.9" sig=6 res=1
авг 19 13:57:17 dssl audit: BPF prog-id=73 op=LOAD
авг 19 13:57:17 dssl audit: BPF prog-id=74 op=LOAD
авг 19 13:57:17 dssl audit: BPF prog-id=75 op=LOAD
авг 19 13:57:17 dssl kernel: audit: type=1334 audit(1629370637.241:1087): prog-id=73 op=LOAD
авг 19 13:57:17 dssl kernel: audit: type=1334 audit(1629370637.241:1088): prog-id=74 op=LOAD
авг 19 13:57:17 dssl kernel: audit: type=1334 audit(1629370637.241:1089): prog-id=75 op=LOAD
авг 19 13:57:17 dssl systemd[1]: Started Process Core Dump (PID 186366/UID 0).
авг 19 13:57:17 dssl kernel: audit: type=1130 audit(1629370637.244:1090): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-coredump@11-186366-0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
авг 19 13:57:17 dssl audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-coredump@11-186366-0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
авг 19 13:57:17 dssl systemd-coredump[186367]: [🡕] Process 186345 (jenotg) of user 1000 dumped core.
                                                  
                                                  Stack trace of thread 186365:
                                                  #0  0x00007fdadaacad22 raise (libc.so.6 + 0x3cd22)
                                                  #1  0x00007fdadaab4862 abort (libc.so.6 + 0x26862)
                                                  #2  0x00007fdad887c9bc n/a (/home/iivanov/.local/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5Core.so.5 + 0x929bc)
                                                  #3  0x0000000000000000 n/a (n/a + 0x0)
авг 19 13:57:17 dssl systemd[1]: [email protected]: Deactivated successfully.
авг 19 13:57:17 dssl kernel: audit: type=1131 audit(1629370637.781:1091): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-coredump@11-186366-0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
авг 19 13:57:17 dssl audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-coredump@11-186366-0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
авг 19 13:57:17 dssl audit: BPF prog-id=75 op=UNLOAD
авг 19 13:57:17 dssl audit: BPF prog-id=74 op=UNLOAD
авг 19 13:57:17 dssl audit: BPF prog-id=73 op=UNLOAD
авг 19 13:57:17 dssl kernel: audit: type=1334 audit(1629370637.964:1092): prog-id=75 op=UNLOAD
авг 19 13:57:17 dssl kernel: audit: type=1334 audit(1629370637.964:1093): prog-id=74 op=UNLOAD
авг 19 13:57:17 dssl kernel: audit: type=1334 audit(1629370637.964:1094): prog-id=73 op=UNLOAD

system test: cli

run jenot.py --jenkins_url ... from console to make sure it works as whole

system test: gui

run jenot-gui.py --jenkins ... and perform some clicks on gui to make sure it works as a whole

Tests for qt

  • learn how tests are done for apps using qt loops and objects
  • add some qt tests

Crash when valid generic jenkins url is pasted instead of build url

2022-03-22 15:07:52,913 - ERROR - failed to parse api response; got this:
_class: org.jenkinsci.plugins.workflow.job.WorkflowJob
buildable: true
builds:
- _class: org.jenkinsci.plugins.workflow.job.WorkflowRun
  number: 138
...

Traceback (most recent call last):
  File "/mnt/filedump/git/jenot/src/jenot/__init__.py", line 48, in iterate
    if resp['building']:
KeyError: 'building'
2022-03-22 15:07:52,936 - ERROR - unhandled exception:
Traceback (most recent call last):
  File "/mnt/filedump/git/jenot/src/jenot/qt/processor.py", line 30, in _run
    result = run(self.jenkins_base_url, self.user, self.token, self.build_part)
  File "/mnt/filedump/git/jenot/src/jenot/__init__.py", line 68, in run
    result, actual_url = iterate(url, USER, TOKEN)
  File "/mnt/filedump/git/jenot/src/jenot/__init__.py", line 48, in iterate
    if resp['building']:
KeyError: 'building'
NoneType: None

Strip redirect from links

Links (usually redirecting to Blue Ocean) can have /display/redirect postfix after build name. Should strip it too in addition to consoleText

http://build.lan/job/stufffjob/PR-1/1/display/redirect

Dark mode support

Might not be needed, if the problem is in my broken linux. Needs testing on some separate installation.

Blue Ocean links support

Instead of a plain old format like

http://build.lan/job/stuff/job/PR-1/1

Links in Blue Ocean GUI look like

http://build.lan/blue/organizations/jenkins/stuff/detail/PR-1/1/

jenkins base url mismatch leads to unreadable errors

.jenotrc: http://localhost:8080
pasted url: http://bar:8080/job/...

Traceback (most recent call last):
  File "s:\git\jenot\src\jenot\qt\processor.py", line 34, in _run
    result = run(self.jenkins_base_url, self.user, self.token, self.build_part)
  File "s:\git\jenot\src\jenot\__init__.py", line 69, in run
    result, actual_url = iterate(url, USER, TOKEN)
  File "s:\git\jenot\src\jenot\__init__.py", line 40, in iterate
    resp = requests.get(f'{url}/api/json', auth=auth).json()
  File "s:\git\Jenot\venv\lib\site-packages\requests\models.py", line 910, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Python\39\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Python\39\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python\39\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

support only full urls for builds

  • it's literally easiser to copypaste full build url, than to construct a partial one
  • gui dialog already supports only urls with scheme
  • it will simplify the code too

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.