title: How to call jenkins shared library method in jenkinsFile
body: <h2>Description</h2>
  <p>I am converting my project jenkinsfiles to shared library, create re-usable methods in groovy. I am using extended_choice_parameter plugin for parameterized build in Jenkins. I use this to pass values like cluster, stage, credentials etc to jenkins job.
  Now i want to use Jenkins shared library where i can define functions with parameters and call them in jenkinsfile with arguments.</p>
  <h2>Problem</h2>
  <p>While using shared library for parameters which is a block inside &quot;pipeline&quot; in jenkinsFile, i am getting error related to usage of parameter function. I have created this file <strong>jobParams.groovy</strong></p>
  <pre><code>List commonParams() {
       //return list of parameters
       def paramsList = [
          choice(name: 'stage', choices: ['lab', 'dev', 'qa', 'uat', 'prod'], description: 'select stage name' ),
          choice(name: 'playbook',
                  choices: [  '',
                              'Linux',
                              'Unix',
                              'CentOS',
                              'Ubuntu',
                              'Debian'
                            ],
                  description: 'select the playbook to deploy'
                ),
          credentials(name: 'sshCredentialsId', defaultValue: 'lc_ikep_ansible', credentialType: &quot;Username with password&quot;, required: true, description: 'SSH credentials for Ansible' ) ,
          string(name: 'ansibleTags', defaultValue: '', description: 'Type in ansibleTags separated by space, example: &quot;pre-install ikep-acls&quot;'),
          string(name: 'extraVars', defaultValue: '', description: 'Type in extraVars in format: --extra-vars=\'{key1: {key2: \&quot;value2\&quot;, key3: \&quot;value3\&quot;}}\''),
          choice(name: 'verboseLogging', choices: ['', '-v', '-vvv', '-vvvv'], description: 'Select ansible verbose logging'),
          booleanParam( name: 'forceDeploy',
                        defaultValue: false,
                        description: 'Activate to force deployment for non-master branches'
                      )
       ]
  
       return paramsList
  
  }
  </code></pre>
  <p>Now i am calling this List in jenkinsfile as these parameters are generated before we click BUILD in jenkins.
  Using following code, i am able to print all the parameters defined in LIST above. But now how can i use this as parameter to generate build parameters in Jenkins.</p>
  <pre><code>/* Pipeline */
  def commonParams = jobParams.commonParams()
      String listAsString =  &quot;[\&quot;${commonParams.join('&quot;, &quot;')}\&quot;]&quot;
      echo &quot;printing variables ${listAsString}&quot;
  </code></pre>
  <p>Please suggest as i did not find a valid usecase while searching internet. Inside <strong>pipeline block in jenkins file</strong> I tried following but it gives error stating</p>
  <pre><code>pipeline {
    agent { label &quot;ansibleDeployments&quot;}
    options { 
      ansiColor('xterm') 
      disableConcurrentBuilds()
      }
    environment {
      ansibleTags = 'all'
      }
    parameters {
      (listAsString)
      }
  </code></pre>
  <p><strong>ERROR</strong></p>
  <pre><code>WorkflowScript: 67: Expected a build parameter definition @ line 67, column 5.
         (listAsString)
         ^
  </code></pre>