Skip to content

Instantly share code, notes, and snippets.

@sturman
sturman / script.groovy
Last active November 9, 2021 10:54
List all Jenkins jobs and count build duration for each in sum for a period of time
def daysBefore = 30
def currentMillis = System.currentTimeMillis()
def cutOfDate = System.currentTimeMillis() - 1000L * 60 * 60 * 24 * daysBefore
long sumDurationMillis = 0
for (job in Jenkins.instance.getAllItems(Job.class)) {
def job_name = job.getFullName()
long durationMillis = 0
@sturman
sturman / Jenkinsfile
Created December 9, 2020 12:39
Running integration tests using testcontainers on Jenkins with the Kubernetes Plugin
def pod =
"""
apiVersion: v1
kind: Pod
metadata:
labels:
name: worker
spec:
serviceAccountName: jenkins
containers:
@sturman
sturman / Jenkinsfile
Created November 23, 2020 21:02
Jenkins pipeline that demonstrates how to abort previous pull request build when new changes are pushed
@NonCPS
def cancelPreviousBuilds() {
def jobName = env.JOB_NAME
def buildNumber = env.BUILD_NUMBER.toInteger()
def ghPrId = env.ghprbPullId.toInteger()
/* Get job name */
def currentJob = Jenkins.instance.getItemByFullName(jobName)
/* Iterating over the builds for specific job */
@sturman
sturman / argo-set-pw
Created October 19, 2020 14:39 — forked from tetchel/argo-set-pw
update password for argocd user
#!/usr/bin/env bash
# https://argoproj.github.io/argo-cd/faq/#i-forgot-the-admin-password-how-do-i-reset-it
username=$1
password=$2
if [[ -z $username || -z $password ]]; then
echo "Usage: $0 \$username \$password"
echo "Missing username or password argument"
apiVersion: v1
kind: Namespace
metadata:
name: echoserver
---
apiVersion: v1
kind: Service
metadata:
name: echoserver
namespace: echoserver
@sturman
sturman / list_docker_image_tags.sh
Last active February 8, 2019 10:19
List docker image tags
#!/usr/bin/env bash
IMAGE_NAME=node
# sudo apt install jq
wget -q https://registry.hub.docker.com/v1/repositories/${IMAGE_NAME}/tags -O - | jq .[].name
# OR
curl -s https://registry.hub.docker.com/v1/repositories/${IMAGE_NAME}/tags | jq .[].name
@sturman
sturman / get-default-clean-redis.conf
Created December 12, 2018 08:58
simple bash script to download default redis.conf and remove all comments and empty lines from it
#!/usr/bin/env bash
function removeComments() {
# remove line that starts with #
sed '/^#/ d' < redis_default.conf > redis_default_without_comments.conf
# remove line that starts with space
sed '/^[[:space:]]*$/d' < redis_default_without_comments.conf > redis_default_clean.conf
}
wget http://download.redis.io/redis-stable/redis.conf -O redis_default.conf
removeComments
@sturman
sturman / convert_edem.tv_playlist.sh
Last active December 4, 2018 08:46
Prepare edem.tv playlist as described here http://epg.it999.ru/
#!/usr/bin/env bash
if [[ $# -lt 2 ]]; then
echo "Please specify parameters"
echo "For example, ./convert_edem.tv_playlist.sh ABCDE123456 123456abc"
exit 1
fi
ACCESS_KEY=$1
DOMAIN=$2
@sturman
sturman / bitbucket-backup-all-repos.sh
Last active October 26, 2018 13:45 — forked from nixjobin/bitbucket-backup-all-repos.sh
bitbucket-backup-all-repos.sh
#!/bin/bash
#Author Jobin Joseph
#Blog : JobNix.in
#Bio : JobinJoseph.com
#Bitbucket credentials
bbuser='Username_here'
bbpass='password_here'
fname=`date +%F_%H_%M`
@sturman
sturman / check htpasswd match
Last active May 13, 2024 06:29
Bash script for checking if hash matches the password. May be useful during configuring Apache or nginx basic authentication
#!/usr/bin/env bash
# https://httpd.apache.org/docs/2.4/misc/password_encryptions.html
# $ htpasswd -nbm sturman Passw0rd > .htpasswd
# $ ./check_pass.sh .htpasswd sturman Passw0rd
HTPASSWD=$1
USERNAME=$2
PASSWORD=$3
ENTRY=$(grep "^$USERNAME:" < "$HTPASSWD")