Skip to content

Instantly share code, notes, and snippets.

@rakeyshkande
rakeyshkande / Jenkinsfile
Created March 31, 2018 19:08 — forked from jonico/Jenkinsfile
Example for a full blown Jenkins pipeline script with multiple stages, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, stage timeouts, stage concurrency constraints, ...
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
/*
Please make sure to add the following environment variables:
HEROKU_PREVIEW=<your heroku preview app>
HEROKU_PREPRODUCTION=<your heroku pre-production app>
HEROKU_PRODUCTION=<your heroku production app>
@rakeyshkande
rakeyshkande / Jenkinsfile
Created February 4, 2018 05:35 — forked from ysegorov/Jenkinsfile
Jenkinsfile example
#!/usr/bin/env groovy
// https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy
// http://stackoverflow.com/a/40294220
// https://JENKINS_HOST/scriptApproval/ - for script approval
import java.util.Date
def isMaster = env.BRANCH_NAME == 'master'
def isDevelop = env.BRANCH_NAME == 'develop'
@rakeyshkande
rakeyshkande / Jenkinsfile
Created February 4, 2018 05:34 — forked from cccaternberg/Jenkinsfile
Jira_Jenkinsfile
node {
stage('Jira-Create-Task') {
withEnv(['JIRA_SITE=local']) {
def testIssue = [fields: [ project: [key: 'AUG2'],
summary: 'New JIRA Created from Jenkins.',
description: 'New JIRA Created from Jenkins.',
issuetype: [name: 'Task']]]
@rakeyshkande
rakeyshkande / Jenkinsfile
Created February 4, 2018 05:33 — forked from radu-matei/Jenkinsfile
Jenkinsfile-k8s
podTemplate(label: 'mypod', containers: [
containerTemplate(name: 'docker', image: 'docker', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.0', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'helm', image: 'lachlanevenson/k8s-helm:latest', command: 'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
]) {
node('mypod') {
@rakeyshkande
rakeyshkande / get_sslFingerprints.sh
Created February 4, 2018 05:32 — forked from brianoflan/get_sslFingerprints.sh
How to get sha256 fingerprints for use with Jenkins Swarm client's -sslFingerprints option
#!/bin/bash
sslFingerprint=$(echo \
| openssl s_client -showcerts -connect $some_jenkins_server_fqdn_name:443 2> /dev/null \
| openssl x509 -noout -sha256 -fingerprint | awk -F'=' '{print $NF}')
# Note that you can strip the colons for a shorter fingerprint:
echo $sslFingerprint | tr -d ':'
# But you do not need to strip them.
@rakeyshkande
rakeyshkande / en_de_crypt.sh
Created February 4, 2018 05:32 — forked from brianoflan/en_de_crypt.sh
Encrypt and decrypt short strings with the user's default SSH key pair
#!/bin/bash
# Encrypts and decrypts short strings with the user's default SSH key pair.
# USAGE:
# encrypt file: cat some_short_file.txt | encrypt_str
# encrypt variable: echo "$some_variable" | encrypt_str
# decrypt file: cat something.encrypted | decrypt_str
# decrypt variable: echo "$string" | decrypt_str
#
@rakeyshkande
rakeyshkande / git
Created February 4, 2018 05:31 — forked from brianoflan/git
Wrap git to add a ticket number to every commit (put this earlier in your PATH than /usr/bin/git)
#!/bin/bash
REAL_GIT=${REAL_GIT-/usr/bin/git}
TICKET_PREFIX=TICKET-PREFIX- # Like JIRA-, REDMINE-, CLEARQUEST- or something.
TICKET_REGEX="${TICKET_PREFIX}[0-9][0-9]*"
main() {
local command=$1
shift
if [[ commit == $command ]] || [[ ticket == $command ]] ; then
get_ticket
@rakeyshkande
rakeyshkande / jenkinsfile.md
Created February 4, 2018 05:28 — forked from amitthk/jenkinsfile.md
jenkinsfile input
stage 'promotion'
def userInput = input(
 id: 'userInput', message: 'Let\'s promote?', parameters: [
 [$class: 'TextParameterDefinition', defaultValue: 'uat', description: 'Environment', name: 'env'],
 [$class: 'TextParameterDefinition', defaultValue: 'uat1', description: 'Target', name: 'target']
])
echo ("Env: "+userInput['env'])
echo ("Target: "+userInput['target'])
@rakeyshkande
rakeyshkande / Jenkinsfile
Created February 4, 2018 05:27 — forked from moondev/Jenkinsfile
Jenkinsfile
node {
checkout scm
//checkout jenkinsfunctions to subdir and load
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'groovyfunctions']],
submoduleCfg: [],
@rakeyshkande
rakeyshkande / Jenkinsfile
Created February 4, 2018 05:27 — forked from brianoflan/Jenkinsfile
Exhaustive Jenkinsfile
#!/usr/bin/env groovy
CLEAN = true
DEBUG = 2
OVERALL_TIMEOUT = 1 // minutes
email_to = 'person2@someOrg.net, person3@gmail.com, '
git_creds = 'general-deploy-key-1'
git_url = 'git@gitlab.some.domain.tld:someNamespace/someProject.git'
branch = ''
default_branch = 'master' // Ignored if Jenkinsfile is pulled from SCM - in favor of that Jenkinsfile's SCM branch.