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

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

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

Amit Chettri
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=[hidden email]',
  'Email_To=[hidden email]',
  '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}"
    }
  }
}

--
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/693d2203-d277-4299-af84-ef1b71c6db40n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

Amit Chettri
Any Jenkins expert can help me with this query?

On Tue, Feb 23, 2021 at 12:22 AM Amit Chettri <[hidden email]> wrote:
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=[hidden email]',
  'Email_To=[hidden email]',
  '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}"
    }
  }
}

--
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/693d2203-d277-4299-af84-ef1b71c6db40n%40googlegroups.com.

--
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/CAAAufFq_WHobfTQ8B9jMZFH6xmfBJsUg2-G0eObCRcNK1sE0fw%40mail.gmail.com.