Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jenkins Pipeline code Examples
// clone in sub-directory
checkout([
$class: 'GitSCM',
branches: [[name: 'master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[
$class: 'RelativeTargetDirectory',
relativeTargetDir: 'some/path'
]],
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: 'a9fb86e4-bd29-425f-a834-16efe6009d84',
url: 'ssh://myuser@my-gerrit-repo.com:22/myproject'
]]
])
// 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}.
getParameter("MY_PARAM_NAME").
value
// Launch Shell with variables and ascii color highlighting
dir('some/path') {
withEnv(["MY_ENV_VAR=${multilineString}"]) {
ansiColor('gnome-terminal') {
sh 'echo "$MY_ENV_VAR"'
}
}
}
@dyennam

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.