Skip to content

Instantly share code, notes, and snippets.

@lepffm
lepffm / init-git-hook-script.cmd
Last active October 25, 2017 12:52
git pre-push hook script for windows
@echo off
@rem init script for git pre-hook ( run findbugs )
@rem writer xxx@xxx.com
@rem check git hook available ( for eclipse )
set CYG_FILE=cygpath.exe
set HOOK_FILE=".git\hooks\pre-push"
@for %%i in (%CYG_FILE%) do @if NOT "%%~$PATH:i"=="" GOTO WRITE_HOOK
@lepffm
lepffm / gist:a538f4db9186e73a1e46165b6e38abc9
Created May 1, 2018 01:40 — forked from int128/gist:14255ff1b1ed11ce1f661a7d35954c2b
How to execute a remote command on the Jenkins Script Console
import hudson.util.RemotingDiagnostics;
def node = 'node-name'
def command = 'uname -a'
println RemotingDiagnostics.executeGroovy("""
def p = '$command'.execute()
p.waitFor()
println p.in.text
import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import hudson.plugins.sshslaves.*;
domain = Domain.global()
store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore()
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
# This name uniquely identifies the PVC. Will be used in deployment below.
name: minio-pv-claim
labels:
app: minio-storage-claim
spec:
# Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
accessModes:
*/terraform.tfvars
*/terraform.tfstate
*/terraform.tfstate.backup
*/.terraform
*/mykey*
rsync -h -v -r -P -t -l /var/lib/jenkins/ /vagrant/forVm/jenkins/
@lepffm
lepffm / build-jenkins.sh
Created August 9, 2019 05:05 — forked from arilivigni/build-jenkins.sh
Jenkinsfile-runner example
#!/bin/bash
set -x
set -e
# Clone the repo
git clone https://github.com/jenkinsci/jenkinsfile-runner.git
pushd jenkinsfile-runner
@lepffm
lepffm / site-healthcheck-to-slack-notification-pipeline.groovy
Last active October 2, 2019 04:28
site healthcheck to slack notification pipeline
/*
* site healthcheck to slack notification pipeline
*
*/
pipeline {
agent any
triggers {
pollSCM('H/10 * * * *') // every 10 min
}
environment {
@lepffm
lepffm / jenkins-read-vault-pipeline-example.groovy
Created October 4, 2019 05:11
jenkins read hashicorp vault pipeline example
pipeline {
agent any
environment {
VAULT_TOKEN = 'YOUR_VAULT_TOKEN'
VAULT_API_ADDR = 'YOUR_VAULT_URL/v1'
}
stages {
stage("read vault"){
steps {
script{
@lepffm
lepffm / count_build_in_job.groovy
Last active October 8, 2019 06:39
count build in all jenkins job
def MIN = 500 // minimum count
Jenkins.instance.getAllItems(AbstractProject.class).sort{ it.builds.size() }.reverse().findAll{ it.builds.size() > MIN }.each{
println it.absoluteUrl + "," + it.builds.size()
}
return