How to use the Advanced Select options plugin for a checkbox

I am currently using the Choice parameter to enter the hostname in the dropdown as shown below.

  • server1
  • server2
  • server3

I am including the selected value in the property.

Server=%Hostname%

      

Also I am calling the same in post build actions-->Email Notification-->Subject-->Login

success for $Hostname

.

But my requirement is instead of the dropdown I need to check the box for server1, server2 and server3 so that I can select multiple servers at the same time and build the job.

Also I need to specify the hostname in the property and in the subject line. But the email subject should not contain the actual host (server) name, it should be a different name instead.

Let's say

server1 = DEV
server2 = QA

      

The property must be "server1" and the eject-suject must be "DEV".

I am trying to use the Advanced Parameter Plugin but I am stuck so any help would be really appreciated!

+3


source to share


2 answers


The advanced selection plugin is the way to go for such a requirement. You need to select Extended Choice Parameter

from the dropdown as shown below.

enter image description here

After selecting this option, you will see another dropdown menu named Parameter Type

as shown in the snapshot below. Select Multi Select

from the dropdown list. Enter the server names in the field Value

. Comma ( , ) is the delimiter.

enter image description here

Now if you run the echo "Server: $Hostname"

on * nix systems command after selecting one (or more) servers, you will get all the selected servers in the output file.



Now, to address your query with displaying names such as Dev / QA instead of the actual server names, you obviously have to run a number of scripts. Since you are taking the server names in a string, you first need to split the string using a comma (,) as a delimiter in order to retrieve the individual values ​​(servers). And then you will check each server and assign values ​​to it. Pseudocode, for example:

if ( str eq server1 ) {
    host = QA;
} elsif ( str eq server 2 ) {
    host = Dev;
} and so on...

      

I wrote a similar script in Perl a few years ago. You can use your language of choice (bash, batch, etc.)

To pass these variables in the subject line of your mail, etc., you will need to use the EnvInject Plugin as suggested by Slav. You can write the value (QA / Dev) in some file when you run the if ... else code so that it can later be used by the EnvInject plugin. Just in case, if you want an alternative way, you can simply use the system mail command depending on your taste.

+3


source


With the advanced selection option, you can toggle between dropdown / multi-selector / checkbox / radio button by choosing a value called "Option Type". If you don't see this, you probably have a very old version of this plugin.



Regarding the second part of your question: you will need to do this mapping in your scripts, put it in EnvInject and then use the entered value in your email

0


source







All Articles