Jenkinsfile: Build job does not pass parameters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Jenkinsfile: Build job does not pass parameters

Adrian Wyssmann
I have a shared library which reads parameters from the jenkinsfile so here is the important snippet of the shared library (defaultCiPipelineGeneric.groovy)
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 {
...

The pipeline is then uses as follows (e.g. in jenkins-pipeline-demo-generic):
library identifier: "pipeline-helper@master"

defaultCiPipelineGeneric {
    nodes               = 'windows-test'
    buildScript         = 'build.groovy'
}


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
               }
            }
         }
      }
   }
}

So I have a problem as if I trigger the jenkins-pipeline-demo with one of the parameters (e.g. isDebug) this parameter is not passed down.

What I do wrong?


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4cd1dc5d-dad1-4799-b2cc-a99efb70e74dn%40googlegroups.com.