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 / 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 / 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 / mvn-clean-recursive
Created April 18, 2018 08:45
Bash script to execute mvn clean for all sub directories containing a pom.xml
#!/usr/bin/env bash
#
# executes mvn clean for all sub directories containing a pom.xml
#
find . -name "pom.xml" -exec mvn clean -f '{}' \;
@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 August 11, 2022 10:57
Configure a secret text credential in Jenkins using a post-initialization script (https://wiki.jenkins.io/display/JENKINS/Post-initialization+script)
pipeline {
agent any
environment {
SECRET_TEXT = credentials("my-secret-text-crendentials-id")
USERNAME_PASSWORD = credentials("my-username-password-crendentials-id")
}
stages {
@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 June 8, 2021 17:21
Configure global libraries in Jenkins (see https://jenkins.io/doc/book/pipeline/shared-libraries/) using a post-initialization script (see https://wiki.jenkins.io/display/JENKINS/Post-initialization+script)
@Library("my-other-jenkins-lib@other-version") _
pipeline {
agent any
environment {
SECRET_TEXT = credentials("googleChatWebhookCommonSystemTestsStatus")
}