Skip to content

Instantly share code, notes, and snippets.

@imander
imander / jenkins-cli.py
Last active February 3, 2021 04:26
Fake CLI for Jenkins script console
#!/usr/bin/env python
# expect creds to be configured in ~/.netrc
import sys
from urllib.parse import urlparse, urlunparse
import requests
script = r"""
def sout = new StringBuilder(), serr = new StringBuilder()
@imander
imander / delete_failed_jobs.groovy
Created January 26, 2021 22:23
Delete all failed Jenkins Jobs
def jobnames = Jenkins.instance.getJobNames()
jobnames.each {
println("Checking Job: ${it}");
def job = Jenkins.instance.getItemByFullName(it)
job.getBuilds().each {
if (it.result == Result.FAILURE) {
// Delete failed job
it.delete()
}
}