Skip to content

Instantly share code, notes, and snippets.

View mkutz's full-sized avatar

Michael Kutz mkutz

View GitHub Profile
@mkutz
mkutz / git-restore
Last active February 5, 2018 09:06
Bash script to restore a deleted file within a Git repository.
#!/usr/bin/env bash
#
# restores the given file if known to git
#
if [ $# -ne 1 ]; then
echo "No file given."
echo -e "\nUsage:\n\t$(basename $0) [file_to_restore]"
exit 1
@mkutz
mkutz / seedjob.groovy
Created February 27, 2018 08:50
This Seedjob creates a (single branch) pipeline for Maven library release job.
#!/usr/bin/env groovy
// see https://jenkinsci.github.io/job-dsl-plugin/ and https://jenkinsci.github.io/job-dsl-plugin/#path/pipelineJob
pipelineJob("my-maven-lib") {
displayName("My Maven Lib")
definition {
cpsScm {
scm {
git {
remote {
@mkutz
mkutz / open-log
Created March 14, 2018 14:54
A command line script to open Kibana according to given parameters.
#!/usr/bin/env groovy
/*
* define CLI
*/
def cli = new CliBuilder(usage: "open-log [options]", )
final String DEFAULT_ENVIRONMENT = "prod"
cli.e(longOpt: "environment", args: 1, argName: "environment",
"Environment whose logs should be displayed (either int, pre or prod).\nDefault: ${DEFAULT_ENVIRONMENT}")
@mkutz
mkutz / open-url
Created April 20, 2018 17:44
Simple Groovy script to open an URL under Linux, as well as OSX or Windows.
#!/usr/bin/env groovy
/*
* define CLI
*/
def cli = new CliBuilder(usage: "${this.class.name} [options]")
cli.usage()
/*
* open URL
@mkutz
mkutz / open-jenkins
Created April 20, 2018 18:02
Simple Groovy script to open the Jenkins job right from a code repository, assuming that the job has the same name as the repository.
#!/usr/bin/env groovy
final String JENKINS_URL = "<YOUR JEKINS URL>" // TODO add your Jenkins URL
final String JOB_NAME = new File(".").canonicalFile.name}
/*
* define CLI
*/
def cli = new CliBuilder(usage: "open-jenkins [-b <build-number> [-c OR -t]]")
@mkutz
mkutz / Jenkinsfile
Last active November 12, 2018 10:31
Configure Maven installations in Jenkins using a post-initialization script (https://wiki.jenkins.io/display/JENKINS/Post-initialization+script)
pipeline {
agent any
tools {
maven "3.2.5"
}
stages {
stage("Use maven") {
@mkutz
mkutz / Jenkinsfile
Last active November 13, 2018 11:22
Configure JDK installations in Jenkins using a post-initialization script (https://wiki.jenkins.io/display/JENKINS/Post-initialization+script)
pipeline {
agent any
tools {
jdk "11"
}
stages {
stage("Use java") {
@mkutz
mkutz / GebConfig.groovy
Created January 31, 2019 11:20
GebConfig.groovy using Testcontainers
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions
import org.testcontainers.containers.BrowserWebDriverContainer
baseUrl = "https://michael-kutz.de"
driver = {
new ChromeDriver()
@mkutz
mkutz / Jenkinsfile
Last active March 22, 2019 08:02
This Jenkinsfile describes a pipeline to build and (optinally) release a Maven library.
#!/usr/bin/env groovy
// see https://jenkins.io/doc/book/pipeline/syntax/
pipeline {
agent any
tools {
maven "Maven"
}
@mkutz
mkutz / GebConfig.groovy
Created March 30, 2019 12:07
Sophisticated GebConfig.groovy using headless or testcontainers
import io.github.bonigarcia.wdm.WebDriverManager
import org.openqa.selenium.Platform
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions
import org.openqa.selenium.remote.CapabilityType
import org.openqa.selenium.remote.DesiredCapabilities
import org.testcontainers.containers.BrowserWebDriverContainer
/*