Jenkins: how could I access Generic Webhook Trigger Parameters from Pipeline script from SCM

931 Views Asked by At

I setup the pipeline which has

  • General Webhook Trigger: I added the variable of Post content parameters like this:

build triggers

  • Declarative pipeline script: this script resided in Bitbucket repository:
@Library("pipeline-shared-lib")_
buildPipeline ([
    GIT_TARGET_BRANCH : "origin/${BRANCH_NAME}",
    GIT_CREDENTIAL_ID : 'xxx',
    GIT_REMOTE_URL: "${REPOSITORY_URL}.git",
    DOCKER_REGISTRY : 'xxx',
    CLEAR_DOCKER_IMAGES : false,
    VERSION_PATH : 'xxx',
    TEAM_WEB_HOOK_URL : "xxx"
])

My problem is when I built this pipe line I faced the error groovy.lang.MissingPropertyException: No such property: BRANCH_NAME for class: groovy.lang.Binding. Please noted that this script ran fine when it was in Jenkins textarea before I moved it to Bitbucket repository. Please give me any clue, I appreciate for all helps.

1

There are 1 best solutions below

0
Pranithan T. On

I am sorry, this is my own mistake.

The error was occurred by running the job manually Build Now button. So, the trigger was not invoked BRANCH_NAME parameter consequently was undefined. )-: