Jenkins Job Build for Maven and Cucumber

Hello World,

Moto: In Jenkins, we all might be having a question which is,
 "How to customize the Jenkins job build with the parameters"
In this blog, we will see the build strategy configuration for the Jenkins job for Maven and cucumber automation project.

Platform: Jenkins 2.121.3
Plugin(s): Active Choices Parameter, Active Choices Reactive Parameter

Solution:

Step 1: Create 3 variables (1- Active Choices Parameter, 2- Active Choices Reactive Parameter)

Step 2: Let's say those variables are the 'BuildStrategy'(Active Choice Parameter), 'Options'(Active Choice Reactive Parameter), and 'Execute'(Active Choice Reactive Parameter)

Step 3: Inject the groovy script for all variables accordingly, as shown below

For 'BuildStrategy' inject this
return ["Build Complete Suite:selected", "Build only selected features", "Build with custom provided tags"]

For 'Options' inject this
if( BuildStrategy.toLowerCase().contains("complete") ){    return ["All Features has been selected now:selected"]}  else if( BuildStrategy.toLowerCase().contains("feature") ){    return ["@Feature1:selected", "Feature2", "@Feature3"]}  else {    return ["Please provide the custom tag below:selected"]}


For 'Execute' inject this
if(BuildStrategy.toLowerCase().contains("complete")) {    return ["clean verify -Dcontext=chrome"];} else if( BuildStrategy.toLowerCase().contains("features") ){    return ["clean verify -Dcontext=chrome -Dcucumber.options=\"--tags " + Options +" \""];} else {    /* Otherwise, execute for the provided tags */    return ["clean verify -Dcontext=chrome -Dcucumber.options=\"--tags " + TagName +" \""];}
Note: ":selected" set as a default selected value for that parameter


Solution Configuration (Screenshot):
1- 
2-

3- 

4- 


Solution Output (Screenshot):

1-

2-

3-


Comments

Popular posts from this blog

Print emojis using python (😀, 👍, ...)

Scraping with Python

Html Status Code