Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Jenkins Pipeline code Examples
// clone in sub-directory
$class: 'GitSCM',
branches: [[name: 'master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[
$class: 'RelativeTargetDirectory',
relativeTargetDir: 'some/path'
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: 'a9fb86e4-bd29-425f-a834-16efe6009d84',
url: 'ssh://'
// Get parameter value of an existing build from another job
// this fails in sandbox
def job = Jenkins.instance.getItemByFullName("My Job")
def build = job.getBuildByNumber(buildNum.toInteger())
// println build.getEnvVars().get('CUCUSHIFT_CONFIG', null)
paramValue = build.allActions.
find {it in hudson.model.ParametersAction}.
// Launch Shell with variables and ascii color highlighting
dir('some/path') {
withEnv(["MY_ENV_VAR=${multilineString}"]) {
ansiColor('gnome-terminal') {
sh 'echo "$MY_ENV_VAR"'

This comment has been minimized.

Copy link

dyennam commented Jan 22, 2019

Hi, Just a quick question:
Shouldn't line 20 say buildNumber.toInteger() ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.