Skip to content

Instantly share code, notes, and snippets.

View rtyler's full-sized avatar

R. Tyler Croy rtyler

View GitHub Profile
@rtyler
rtyler / check-updates
Created September 28, 2018 18:57
A simple script to update a pom.xml for the latest updates
#!/usr/bin/env bash
DEPENDS=$(xmlstarlet sel -N x='http://maven.apache.org/POM/4.0.0' \
-t -m x:project/x:dependencies/x:dependency \
-v x:artifactId -o ' ' \
pom.xml)
if [ ! -f update-center.actual.json ]; then
wget https://updates.jenkins.io/update-center.actual.json;
fi;
@rtyler
rtyler / upload-to-azure.sh
Created January 4, 2018 19:22
A bash script which supports uploading blobs to Azure Storage: ./upload-to-azure.sh [filename]
#!/usr/bin/env bash
FILENAME=${1}
# expected to be defined in the environment
# - AZURE_STORAGE_ACCOUNT
# - AZURE_CONTAINER_NAME
# - AZURE_ACCESS_KEY
# inspired by
@rtyler
rtyler / find-ed25519.groovy
Last active October 12, 2018 18:35
Determine whether there are passphrase-protected ed25519 keys in a Jenkins instance
import com.cloudbees.hudson.plugins.folder.*
import com.cloudbees.hudson.plugins.folder.properties.*
import com.cloudbees.hudson.plugins.folder.properties.FolderCredentialsProvider.FolderCredentialsProperty
import com.cloudbees.plugins.credentials.*
import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey
/* Let's see if the key is ed25518 */
boolean checkKey(def key) {
boolean found = false
#!/bin/sh
exec docker run --rm -ti -p 8080:8080 -e GITHUB_USER=rtyler -v $PWD/init.groovy.d:/var/jenkins_home/init.groovy.d -e CLIENT_SECRET=foobar -e CLIENT_ID=foobar -e AZURE_SUBSCRIPTION_ID=fooar -e AZURE_TENANT_ID=FOOBAR -e AZURE_CLIENT_ID=FOOBAR-e AZURE_CLIENT_SECRET="FOOBAR" rtyler/codevalet-master
Set-ExecutionPolicy Unrestricted
$jenkinsServerUrl = $args[0]
$vmName = $args[1]
$secret = $args[2]
$jenkinsSlaveJarUrl = $jenkinsServerUrl + "jnlpJars/slave.jar"
$jnlpUrl=$jenkinsServerUrl + 'computer/' + $vmName + '/slave-agent.jnlp'
$baseDir = 'c:\azurecsdir'
$JDKUrl = 'http://cdn.azul.com/zulu/bin/zulu8.17.0.3-jdk8.0.102-win_x64.zip?jenkins'
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
@rtyler
rtyler / 0_console.log
Created December 9, 2016 00:18
Demonstrating setters/getters in a Pipeline Shared Library
Started by user rtyler
Loading library pipeline-library@acme-test
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git://github.com/jenkins-infra/pipeline-library.git # timeout=10
Fetching upstream changes from git://github.com/jenkins-infra/pipeline-library.git
> git --version # timeout=10
> git fetch --tags --progress git://github.com/jenkins-infra/pipeline-library.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/acme-test^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/acme-test^{commit} # timeout=10
@rtyler
rtyler / 0_error.log
Created December 9, 2016 00:10
Example of an invalid casing for a Global Variable in a Pipeline Shared Library
Started by user rtyler
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 2: unexpected token: Mr Jenkins @ line 2, column 14.
SayHello "Mr Jenkins"
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:150)
#!/usr/bin/env groovy
node {
stage('Build') {
sh 'make'
}
stage('Test') {
sh 'make check' /* if this returns non-zero, the Pipeline stops */
junit 'reports/**/*.xml'
/* otherwise...we could: */
FROM jetty:9-alpine
# Add our system dependencies for running jetty and node services inside the
# container
RUN apk update && apk add supervisor nodejs
# Bring our Java backend app over for Jetty
COPY target/*.war /var/lib/jetty/webapps/ROOT.war