Skip to content

Instantly share code, notes, and snippets.

View mkutz's full-sized avatar

Michael Kutz mkutz

View GitHub Profile
@mkutz
mkutz / IfDeclarativeJenkinsfile.groovy
Last active August 3, 2020 15:26
Jenkinsfile using when to create an optional stage
#!/usr/bin/env groovy
// see https://jenkins.io/doc/book/pipeline/syntax/
pipeline {
agent any
parameters {
booleanParam(name: "RELEASE", defaultValue: false)
}
@mkutz
mkutz / configureSlack.groovy
Created May 10, 2019 11:58
Configure Slack in Jenkins using a post-initialization script (https://wiki.jenkins.io/display/JENKINS/Post-initialization+script)
import static com.cloudbees.plugins.credentials.CredentialsScope.GLOBAL
import com.cloudbees.plugins.credentials.domains.Domain
import com.cloudbees.plugins.credentials.SystemCredentialsProvider
import hudson.util.Secret
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl
import com.cloudbees.plugins.credentials.CredentialsStore
// Configure the global Slack token as a secret text credential
CredentialsStore credentialsStore = SystemCredentialsProvider.getInstance().getStore()
@mkutz
mkutz / GebScript.groovy
Last active April 26, 2019 15:45
Standalone script using Geb to automate a browser
#!/usr/bin/env groovy
@Grab("org.gebish:geb-core:2.3.1")
@Grab("io.github.bonigarcia:webdrivermanager:3.4.0")
@Grab("org.seleniumhq.selenium:selenium-java:3.141.59")
@Grab("ch.qos.logback:logback-classic:1.2.3")
import geb.Browser
import geb.Configuration
import groovy.cli.OptionField
import groovy.cli.picocli.CliBuilder
@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
/*
@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 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 / Jenkinsfile
Created November 12, 2018 15:48
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 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")
}
@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 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 {