I have a shared library which reads parameters from the jenkinsfile so here is the important snippet of the shared library (
def call(body) {
// evaluate the body block, and collect configuration into the object
def pipelineParams= [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = pipelineParams
body()
pipelineParams = initializePipeline(pipelineParams, pipelineParams.buildType)
pipeline {
agent {
label pipelineParams.nodes
}
triggers {
cron(pipelineParams.schedule)
}
options {
/*
- daysToKeepStr: history is only kept up to this days.
- numToKeepStr: only this number of build logs are kept.
- artifactDaysToKeepStr: artifacts are only kept up to this days.
- artifactNumToKeepStr: only this number of builds have their artifacts kept.
*/
buildDiscarder(logRotator(artifactNumToKeepStr: '1',
daysToKeepStr: "${pipelineParams.logdaystokeep}",
numToKeepStr: "${pipelineParams.lognumtokeep}"))
disableConcurrentBuilds()
timeout(time: pipelineParams.timeout, unit: 'MINUTES')
}
tools {
jdk "${pipelineParams.java}"
nodejs "${pipelineParams.nodejs}"
}
parameters{
booleanParam(
defaultValue: false,
description: 'Enables debug information in the log',
name: 'isDebug')
booleanParam(
defaultValue: false,
description: "Marks the build as 'Release' build which triggers defined release commands e.g. `mvn release`",
name: 'isRelease')
booleanParam(
defaultValue: false,
description: 'Force deployment on deployment nodes as well as run of integration tests - use this parameter with CAUTION as it overrides existing deployments on SIT',
name: 'forceDeployment')
}
stages {
This works fine. I have an "umbrella" jenkins job (jenkins-pipeline-demo) which trigger this (and other jobs)
library identifier: "pipeline-helper@master"
//def pipelineParams = [:]
pipeline {
agent {
label 'devops'
}
parameters {
booleanParam(
defaultValue: false,
description: 'Enables debug information in the log',
name: 'isDebug')
booleanParam(
defaultValue: false,
description: "Marks the build as 'Release' build which triggers defined release commands e.g. `mvn release`",
name: 'isRelease')
booleanParam(
defaultValue: false,
description: 'Force deployment on deployment nodes as well as run of integration tests - use this parameter with CAUTION as it overrides existing deployments on SIT',
name: 'forceDeployment')
}
stages {
stage('Build') {
steps {
script {
build job: '../jenkins-pipeline-demo-generic/master'
parameters: ([] + params)
propagate: propagate
}
}
}
}
}
}