Skip to content

Instantly share code, notes, and snippets.

Avatar

Vasilis zerogvt

  • Greece
View GitHub Profile
@zerogvt
zerogvt / mock_requests.py
Created Jul 23, 2018 — forked from evansde77/mock_requests.py
Example of mocking requests calls
View mock_requests.py
#!/usr/bin/env python
"""
mocking requests calls
"""
import mock
import unittest
import requests
from requests.exceptions import HTTPError
@zerogvt
zerogvt / remove-nodes-safely.sh
Created Jul 20, 2018 — forked from scarytom/remove-nodes-safely.sh
Script to safely de-register jenkins nodes usage: $ remove-nodes-safely.sh my-node-1 my-node-2 my-node-3
View remove-nodes-safely.sh
#!/bin/bash
set -e
set -u
CI_MASTER_URL="http://ci-1"
node_online() {
curl --silent "$CI_MASTER_URL/computer/$1/api/json" | grep --silent '"temporarilyOffline":false'
}
@zerogvt
zerogvt / create-ssh-node.sh
Created Mar 23, 2018 — forked from Evildethow/create-ssh-node.sh
Jenkins: Create SSH node, using bash and curl
View create-ssh-node.sh
#!/usr/bin/env bash
set -o nounset -o errexit -o pipefail
usage() {
cat <<EOM
Usage:
$(basename $0) [OPTIONS]
$(basename $0) [ -j | --jenkins-url | -n | --node-name | -s | -d | --desc | --slave-home | -e | --executors | -sh | --ssh-host | -sp | --ssh-port
| -c | --cred-id | -l | --labels | -u | --user-id | -p | --password | -h | --help ]
@zerogvt
zerogvt / gist:081685d53465f2266e419310fcca304a
Last active Feb 2, 2021 — forked from rb2k/gist:8372402
A jenkins script to clean up workspaces on slaves
View gist:081685d53465f2266e419310fcca304a
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.flow.FlowExecution;