Execute Build Step Based On Parameter Value

Bob Cook

I have a Jenkins job in which I have defined 2 Execute Shell Build Steps (call them Step1 and Step2. I also have as part of this job a Choice Parameter with 2 choices (for the sake of this example let's also call those values Step1 and Step2). What I am trying to do is if the user selects Step1 as the choice parameter then the job would only execute the Step1 build step, if user selects Step2 it would only select the Step2 build step. I was thinking that I could put a groovy step in front of these to control this behavior but not sure how to construct this. I could also just define a single choice parameter and condition such that if choice = step1 then execute step1 else execute step2......still not sure how to construct that syntax. I'll keep trying a few different things but if anyone has done this any assistance would be appreciated.

Gerold Broser

From Parameterized Build:

The parameter are available as environment parameters variables. So e.g. a shell ($FOO, %FOO%) or Ant ( ${env.FOO} ) can access these values.

[Correction by me.]

Use the environment variable defined in your Choice Parameter in two Conditional BuildSteps, one for each of your steps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Execute Build Step Based On Parameter Value

From Dev

Accessing a Username with Password Credential Parameter from a Jenkins Execute Groovy build step using Groovy command?

From Dev

Skip step based on job parameter

From Dev

Skip step based on job parameter

From Dev

Pass parameter from build step to post-build step in Jenkins

From Dev

Jenkins - Build step 'Execute shell' marked build as failure in linux environment

From Dev

Optional promise-step based on query parameter

From Dev

TeamCity - Specifying the previous build version as build step parameter

From Dev

Loop based on parameter value

From Dev

Execute insert query from stored procedure result set based on output parameter value

From Dev

Configure Gradle to execute custom build step before starting compilation

From Dev

Is it possible to set an VSTS Build variable in a Build Step so that the value can be used in a subsequent Build Step?

From Dev

Set Jenkins label to value of build parameter for truly dynamic node and label based builds

From Dev

Jenkins Promoted Build Parameter Value

From Dev

Jenkins Promoted Build Parameter Value

From Dev

Need Step by Step Guide to execute the Jmeter Scripts in Jenkins (with Hudson build) over Ubuntu

From Dev

Need Step by Step Guide to execute the Jmeter Scripts in Jenkins (with Hudson build) over Ubuntu

From Dev

Access build parameters in Extended Choice Parameter - in promotion step?

From Dev

How to use a parameter from NodeLabelParameter Plugin with the "build" step of Jenkins Workflow

From Dev

Constructor based the value of last parameter?

From Dev

Change query value based on parameter

From Dev

Execute remote script with local parameter value

From Dev

Is it possible to insert value in table based on parameter value

From Dev

Execute shell scripts based on value of key pressed

From Dev

Generate gradient step based on dynamic value, including decimals

From Dev

Choose which function to execute, based on a parameter - its name

From Java

mockito return value based on property of a parameter

From Dev

Conditional WHERE based on SQL Server parameter value

From Dev

SSRS Multiple Value parameter filter based on dataset

Related Related

  1. 1

    Execute Build Step Based On Parameter Value

  2. 2

    Accessing a Username with Password Credential Parameter from a Jenkins Execute Groovy build step using Groovy command?

  3. 3

    Skip step based on job parameter

  4. 4

    Skip step based on job parameter

  5. 5

    Pass parameter from build step to post-build step in Jenkins

  6. 6

    Jenkins - Build step 'Execute shell' marked build as failure in linux environment

  7. 7

    Optional promise-step based on query parameter

  8. 8

    TeamCity - Specifying the previous build version as build step parameter

  9. 9

    Loop based on parameter value

  10. 10

    Execute insert query from stored procedure result set based on output parameter value

  11. 11

    Configure Gradle to execute custom build step before starting compilation

  12. 12

    Is it possible to set an VSTS Build variable in a Build Step so that the value can be used in a subsequent Build Step?

  13. 13

    Set Jenkins label to value of build parameter for truly dynamic node and label based builds

  14. 14

    Jenkins Promoted Build Parameter Value

  15. 15

    Jenkins Promoted Build Parameter Value

  16. 16

    Need Step by Step Guide to execute the Jmeter Scripts in Jenkins (with Hudson build) over Ubuntu

  17. 17

    Need Step by Step Guide to execute the Jmeter Scripts in Jenkins (with Hudson build) over Ubuntu

  18. 18

    Access build parameters in Extended Choice Parameter - in promotion step?

  19. 19

    How to use a parameter from NodeLabelParameter Plugin with the "build" step of Jenkins Workflow

  20. 20

    Constructor based the value of last parameter?

  21. 21

    Change query value based on parameter

  22. 22

    Execute remote script with local parameter value

  23. 23

    Is it possible to insert value in table based on parameter value

  24. 24

    Execute shell scripts based on value of key pressed

  25. 25

    Generate gradient step based on dynamic value, including decimals

  26. 26

    Choose which function to execute, based on a parameter - its name

  27. 27

    mockito return value based on property of a parameter

  28. 28

    Conditional WHERE based on SQL Server parameter value

  29. 29

    SSRS Multiple Value parameter filter based on dataset

HotTag

Archive