Skip to content

Instantly share code, notes, and snippets.

View jakubjosef's full-sized avatar

Jakub Josef jakubjosef

  • Praha || Hradec Králové, Czech Republic
View GitHub Profile
@jakubjosef
jakubjosef / iterm2-solarized.md
Created August 19, 2025 17:12 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@jakubjosef
jakubjosef / gist:755226dd6904dff8ae2c9ffbcaf4388f
Last active January 10, 2024 14:14
Enable TouchID for sudo
1) Go to pam.d directory
cd /etc/pam.d
2) Copy sudo_local_template
sudo cp sudo_local.template sudo_local
3) Change permissions to write to that file
@jakubjosef
jakubjosef / run-failed-jenkins-jobs.groovy
Created November 28, 2017 13:35
Run jenkins jobs with specific name if there is no success run
def jobs = Jenkins.instance.items.findAll { it.name.startsWith("git-mirror")}
for(job in jobs){
if(job.builds.isEmpty() || job.builds[0].result != "SUCCESS"){
build job:job.name, propagate: false, wait: false
}
}
@jakubjosef
jakubjosef / jenkins-clean-before-restart.groovy
Last active November 9, 2017 15:10
Jenkins complete cleanup
def q = Jenkins.instance.queue
q.items.each { q.cancel(it.task) }
for (int i=0; i < Jenkins.instance.items.size(); i++) {
if(!killStuckBuilds(Jenkins.instance.items[i])){
println("Kill failed!")
}
}
def killStuckBuilds(job){
def result = true
@jakubjosef
jakubjosef / jenkins-job-disable.groovy
Created July 24, 2017 13:50
Disable Jenkins jobs with condition
def jobs = Jenkins.instance.items.findAll { it.name.startsWith("test") || it.name.startsWith("deploy") }
def counter = 0
for (job in jobs) {
job.disabled = true
counter++
}
print("Disabled ${counter} jobs")
@jakubjosef
jakubjosef / disable-jenkins-jobs-if-too-much-failures.groovy
Created July 24, 2017 13:43 — forked from thbkrkr/disable-jenkins-jobs-if-too-much-failures.groovy
Groovy script to disable Jenkins Jobs which name contains "ping" or "post" if the last x result builds are failures
def ret = 0
def MAX_FAILURES = 3
def projects = jenkins.model.Jenkins.instance.projects.findAll { it.name.contains("ping") || it.name.contains("post") }
for (p in projects) {
def projectName = p.name
@jakubjosef
jakubjosef / stop-executors-jenkins.groovy
Created July 18, 2017 15:56
Stop all jenkins executors
server_name_pattern = /jsl0[1-9]/
jenkins.model.Jenkins.instance.getComputers().each { computer ->
if (computer.getName().find(server_name_pattern)) {
println computer.getName()
execList = computer.getExecutors()
for( exec in execList ) {
busyState = exec.isBusy() ? ' busy' : ' idle'
println '--' + exec.getDisplayName() + busyState
if (exec.isBusy()) {
exec.stop()
import hudson.model.*
def q = Jenkins.instance.queue
q.items.each { q.cancel(it.task) }
def MAX_DURATION_IN_HOURS = "6"
for (int i=0; i < Jenkins.instance.items.size(); i++) {
if(!killStuckBuilds(3600 * Integer.parseInt(MAX_DURATION_IN_HOURS), Jenkins.instance.items[i])){
println("Kill failed!")
}
}
def killStuckBuilds(maxSeconds, job){
def result = true
def runningBuilds = getRunningBuilds(job)
def jobName = job.name
def jobName = ""
def jobNum = ""
Jenkins.instance.getItemByFullName(jobName).getBuildByNumber(jobNum).finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));