Skip to content

Instantly share code, notes, and snippets.

View agarthetiger's full-sized avatar

Andrew Garner agarthetiger

  • Farnborough, Hampshire, UK
View GitHub Profile
@agarthetiger
agarthetiger / QuotesInJenkinsfiles.groovy
Last active February 15, 2024 10:06
Quoting strings and variable interpolation in Jenkinsfiles, passing values to shell tasks.
node{
timestamps{
stage('Samples'){
// Single quotes with no interpolation, at least not in Jenkins.
// The dollar variable will be evaluated before being run by the
// shell command, so variables which Jenkins makes available as
// environment variables can still be accessed from within a
// single-quoted string, passed to the sh task.
sh 'echo $PATH'
@agarthetiger
agarthetiger / EnvInJenkinsfile.groovy
Created August 29, 2018 16:00
Referencing Env variables with a variable in a Jenkinsfile
// I wrote a Jenkinsfile shared library method to check job parameters for mandatory fields. The
// list of mandatory fields depended on other parameter values. Writing this as a reference because
// it wasn't immediately obvious how to use a (groovy) variable to access an env variable.
properties([
parameters([
string(name: 'MY_PARAM', defaultValue: '1.0.0', description: 'Useful description here.'),
])
])
@agarthetiger
agarthetiger / semaphore.yml
Last active May 24, 2023 14:59
Commands, env vars, quotes and more in Semaphore
version: v1.0
name: Commands in Semaphore
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004
queue:
processing: parallel