Skip to content

Instantly share code, notes, and snippets.

function Get-Boxstarter {
Param(
[string] $Version = "2.12.0",
[switch] $Force
)
if(!(Test-Admin)) {
$bootstrapperFile = ${function:Get-Boxstarter}.File
if($bootstrapperFile) {
Write-Host "User is not running with administrative rights. Attempting to elevate..."
$command = "-ExecutionPolicy bypass -noexit -command . '$bootstrapperFile';Get-Boxstarter $($args)"
@lepffm
lepffm / jenkinsfile-ast-sample.groovy
Created June 24, 2020 01:17
jenkinsfile paser example with modeldefinition plugin ( jenkins script console)
def str = '''
pipeline {
agent any
stages {
stage('Hello') {
steps {
echo 'Hello World'
sh 'pwd'
}
}
@lepffm
lepffm / cloudfront_invalidate_pipeline.groovy
Last active April 17, 2024 12:40
jenkins pipeline script for cloudfront invalidattion
// reference : https://stackoverflow.com/questions/56294317/how-to-programmatically-get-distribution-id-to-invalidate-cloudfront-cache
// prerequisite : aws cli, jq , aws credentials setting
pipeline {
parameters {
stringParam(description: 'your domain name', name: 'domain')
}
agent any
stages{
stage('init'){
steps{
@lepffm
lepffm / How to use variable in post directives of Jenkins pipeline
Last active December 27, 2019 05:14
How to use variable in post directives of Jenkins pipeline example
/*
jenkins pipeline ์˜ post directive ์—์„œ๋Š” ์–ด๋–ค ์ด์œ ๋กœ์ธ์ง€
์ „์—ญ ๋˜๋Š” stage ์—์„œ ์‚ฌ์šฉํ–ˆ๋˜ ๋ณ€์ˆ˜๋‚˜ ํ™˜๊ฒฝ๋ณ€์ˆ˜์˜ ๋ณ€๊ฒฝ๋œ ๊ฐ’์— ์ ‘๊ทผํ•˜์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค.
๋‹ค์–‘ํ•˜๊ฒŒ ์‹œ๋„ํ•ด๋ณธ ๊ฒฐ๊ณผ ํŠธ๋ฆญ์ธ๋“ฏ ํ•˜์ง€๋งŒ
currentBuild.displayName ๋˜๋Š” currentBuild.description ์„ ์ด์šฉํ•˜์—ฌ ์ฒ˜๋ฆฌ ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•˜์—ฌ
post ๋‹จ๊ณ„์—์„œ slack ๋“ฑ์˜ ํˆด์— ๋™์ ์ธ ์ •๋ณด๋ฅผ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
----
description: If you want to use variable on 'post' directives by storing the result message
according to the processing of a specific stage,
you can use currentBuild.displayName or currentBuild.description.
@lepffm
lepffm / helpful-docker-commands.sh
Created November 18, 2019 08:15 — forked from garystafford/helpful-docker-commands.sh
My list of helpful docker commands
###############################################################################
# Helpful Docker commands and code snippets
###############################################################################
### CONTAINERS ###
docker stop $(docker ps -a -q) #stop ALL containers
docker rm -f $(docker ps -a -q) # remove ALL containers
docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter
# exec into container
@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
@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 / 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 / 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