Manoj Bhagwat
Manoj Bhagwat

Reputation: 161

Jenkins Pipeline Fails to load Build parameter (Git parameter plugin)

I want to build job with build parameters in Jenkins pipeline.

  1. Declared a variable in Git parameter plugin
  2. Try to access branch name in script

Unfortunately job is unable to list the branches it is throwing java exception error.

Git parameter plugin configuration

GIT parameter plugin enter image description here

Pipeline script enter image description here

Error on Triggering of job. Error in Build enter image description here

Java exception enter image description here

Upvotes: 1

Views: 6383

Answers (3)

yan
yan

Reputation: 1541

add Branch Filter in Git Parmeter

enter image description here

Upvotes: 1

Manoj Bhagwat
Manoj Bhagwat

Reputation: 161

Below steps worked for me.

1) Add git parameter Add git parameter

2) Call the variable in script and in configuration

Pass same variable name as defined earlier in branch section

Upvotes: 0

Volodymyr Maksymchuk
Volodymyr Maksymchuk

Reputation: 21

You can install Parameterized Build In your Jenkins job configuration tick/select This project is parameterized > Add Parameter > String Parameter

Then in Jenkinsfile I believe you should be able to reference your parameter eg.

branches: [[name: '*/' + PARAMETER_NAME ]],

Upvotes: 1

Related Questions