Skip to content

Instantly share code, notes, and snippets.

@MOURIK
MOURIK / script
Created March 20, 2018 10:48 — forked from fesor/script
Jenkins: script for checking is directory has changed from last build
#!/bin/bash
DIR_PATH=$1
if [ ! -d "$DIR_PATH" ]; then
echo "Directory '$DIR_PATH' not exists"
exit 1
fi
if [ -z "$GIT_COMMIT" ]; then
echo "No current commit... fail"
@MOURIK
MOURIK / create_master_keysource_credential.md
Created December 13, 2017 23:22 — forked from hayderimran7/create_master_keysource_credential.md
Create a new jenkins global credential from a key source on jenkins master(groovy script)

Create a New jenkins global credential from a key stored on jenkins master

This script helps create a global credential in jenkins from a key source that is located in jenkins master.
You can change the name of key to whatever key exists on master.
Run this script either:

i) Jenkins-> manage Jenkins -> script console

ii) add to init.groovy to make it run during jenkins start

@MOURIK
MOURIK / groovy-create-user.md
Created December 13, 2017 23:21 — forked from hayderimran7/groovy-create-user.md
Jenkins Groovy enable security and create a user in groovy script

This is a snippet that will create a new user in jenkins and if security has been disabled , it will enable it :)

import jenkins.model.*
import hudson.security.*

def instance = Jenkins.getInstance()

def hudsonRealm = new HudsonPrivateSecurityRealm(false)
hudsonRealm.createAccount("MyUSERNAME","MyPASSWORD")
instance.setSecurityRealm(hudsonRealm)