Skip to content

Instantly share code, notes, and snippets.

View lvthillo's full-sized avatar

Lorenz Vanthillo lvthillo

View GitHub Profile
@lvthillo
lvthillo / mavenPipeline.groovy
Created March 19, 2018 17:39
Reusable declarative Jenkins pipeline for maven projects
def call(body) {
def rtMaven = ''
def buildInfo = ''
def server = ''
// evaluate the body block, and collect configuration into the object
def pipelineParams= [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = pipelineParams
body()
@lvthillo
lvthillo / SlackNotifier.groovy
Created March 19, 2018 17:56
Groovy function used in Jenkins pipeline to publish build result to Slack
#!/usr/bin/env groovy
def call(String buildResult) {
if ( buildResult == "SUCCESS" ) {
slackSend color: "good", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was successful"
}
else if( buildResult == "FAILURE" ) {
slackSend color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was failed"
}
else if( buildResult == "UNSTABLE" ) {
@lvthillo
lvthillo / docker-compose.yaml
Created March 20, 2018 18:56
docker-compose.yaml to deploy a MySQL Docker container
services:
mysql:
image: mysql:5.7
container_name: mysql
volumes:
- mysql-volume:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
MYSQL_USER: blog-user
@lvthillo
lvthillo / wait-for-it.sh
Created March 20, 2018 18:57
wait-for-it.sh to Check if MySQL service is running using environment variables
#!/bin/bash
set -e
host="$1"
shift
cmd="$@"
until mysql -hmysql -p"3306" -u"${database__connection__user}" -p"${database__connection__password}"
-D"${database__connection__database}" ; do
>&2 echo "MySQL is unavailable - sleeping"
sleep 1
done
@lvthillo
lvthillo / docker-compose.yaml
Created March 20, 2018 19:02
docker-compose.yaml to deploy a full Ghost - MySQL stack in Docker
version: '3.1'
volumes:
mysql-volume:
ghost-volume
services:
mysql:
image: mysql:5.7
container_name: mysql
volumes:
@lvthillo
lvthillo / jenkins-namespace.yaml
Created April 3, 2018 17:34
create jenkins namespace
apiVersion: v1
kind: Namespace
metadata:
name: jenkins-project
@lvthillo
lvthillo / jenkins-volume.yaml
Created April 3, 2018 17:40
Create persistent volume for jenkins in minikube
apiVersion: v1
kind: PersistentVolume
metadata:
name: jenkins-pv
namespace: jenkins-project
spec:
storageClassName: jenkins-pv
accessModes:
- ReadWriteOnce
capacity:
@lvthillo
lvthillo / jenkins-values.yaml
Last active November 12, 2019 20:55
values for helm
clusterZone: "cluster.local"
master:
componentName: "jenkins-master"
image: "jenkins/jenkins"
tag: "lts"
imagePullPolicy: "Always"
imagePullSecretName:
lifecycle:
numExecutors: 0
@lvthillo
lvthillo / pipeline.groovy
Last active May 19, 2024 16:03
Scripted Jenkins pipeline which uses Kubernetes plugin
podTemplate(label: 'mypod', containers: [
containerTemplate(name: 'git', image: 'alpine/git', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
]
) {
node('mypod') {
@lvthillo
lvthillo / slackNotifier.groovy
Created April 11, 2018 20:30
Groovy script to send Slack Notifications
#!/usr/bin/env groovy
def call(String buildResult) {
if ( buildResult == "SUCCESS" ) {
slackSend color: "good", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was successful"
}
else if( buildResult == "FAILURE" ) {
slackSend color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was failed"
}
else if( buildResult == "UNSTABLE" ) {