How to add active choice parameter as input in one of the stage rather then start of pipeline

87 views
Skip to first unread message

Amit Chettri

unread,
Feb 22, 2021, 1:52:05 PM2/22/21
to Jenkins Users
Hello Team, 

After look all the around in the web and not be able to get the solution i am reaching out here.

As of now I have code a test pipeline with 2 stages
  A) stage-1 to scan for the available server from a file in remote remote
  B) Stage-2 list all the server as option to select using extended choice parameter

GOAL: What i want to do is make use of active choice as this give filter option

below code works properly but i want to replace the stage('Select nodes') with active choice rather than extended Choice Parameter. And the build option should be "BUILD NOW rather than BUILD with PARAMETER (as the server info will be dynamic, hence reading the last info will not help"

node {
  withEnv(['Email_From=xx...@domain.com',
  'Email_To=xx...@domain.com',
  'Email_CC=',
  'Email_ReplyTo=',
  'EmailDev=',
  'EmailTest=',
  'EmailProd=',
  'Jenkins_URL=http://jenkins-102.domain.local:8080']) {
    stage('Scan Register Nodes') {
      sh label: "Scanning for registered nodes", script: """ 
        if [[ ! -e ~/tmp_dir ]]; then
          mkdir ~/tmp_dir
        fi
        // cat node_list.lst => will be replace by actualy api query code
        cat node_list.lst > ~/tmp_dir/reg_node_list.lst
        echo "Total Registerd Nodes are as below"
        echo "ALL" >> ~/tmp_dir/reg_node_list.lst
        cat ~/tmp_dir/reg_node_list.lst
      """
    }
    stage('Select nodes') {
      env.servers_list = input message: 'Select the Servers', parameters: [extendedChoice(description: 'Select the Servers to perform the operation in the pipeline', multiSelectDelimiter: ',', name: 'Servers', quoteValue: false, saveJSONParameterToFile: false, type: 'PT_CHECKBOX', groovyScriptFile: "/xxxx/servers.gvy",defaultValue: 'None', visibleItemCount: '20')]

      echo "${servers_list}"
    }
  }
}

Amit Chettri

unread,
Feb 22, 2021, 11:48:53 PM2/22/21
to jenkins...@googlegroups.com
Any Jenkins expert can help me with this query?

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/693d2203-d277-4299-af84-ef1b71c6db40n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages