[Generic Webhook Trigger Plugin]Multiple Resolved Variables in Github Push Payload for single Generic Variable

602 Views Asked by At

I have the generic Variables like one below in my jenkins pipeline

        parameters {
            stringParam('DOCKER_FILE', "", "Select the Dockerfile Directory [dirname] to be built")

        }

        genericVariable {
            key("DOCKER_FILE") //maven-mongodb
            value("\$.head_commit.['modified','added'][*]") //all directory names
            regexpFilter("/Dockerfile")
            expressionType("JSONPath")
        }

But when I see Github push payload body I can see resolved variables as "DOCKER_FILE":"[]" and "DOCKER_FILE_0":"[]"...This is because I have added 2 (modified,added) in which "DOCKER_FILE" will have all values while _0 and _1 will have their own like

https://github.com/jenkinsci/generic-webhook-trigger-plugin/blob/master/src/test/resources/org/jenkinsci/plugins/gwt/bdd/github/github-push-get-changed-files.feature

Scenario:

In my Jenkins Pipeline

For Manual Trigger -> Parameter I have is only DOCKER_FILE and "DOCKER_FILE_0" is undefined

For webhook trigger -> Through Generic Variables I will have both DOCKER_FILE and DOCKER_FILE_0

Query:

**How can I use the value of "DOCKER_FILE_0" in my pipeline for manual trigger?

Or else How can I get "maven-mongodb/file1.txt" from DOCKER_FILE without [] Below are my contributing variables **

During Webhook trigger my Contributing variables:

DOCKER_FILE = ["maven-mongodb/file1.txt","maven-mongodb/file2.txt"]
DOCKER_FILE_0 = maven-mongodb/file1.txt
DOCKER_FILE_1 = maven-mongodb/file2.txt

ie.DOCKER_FILE_0 will be automatically created during push event with generic webhook trigger

0

There are 0 best solutions below