Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is it possible to access data from the different webhooks? #168

Closed
saggl opened this issue Jul 1, 2020 · 2 comments
Closed

How is it possible to access data from the different webhooks? #168

saggl opened this issue Jul 1, 2020 · 2 comments

Comments

@saggl
Copy link

saggl commented Jul 1, 2020

Version:
Generic Webhook Trigger Plugin 1.67
Jenkins 2.199

My situation:

one build is triggered by several webhooks with the same json schema but different data, see code section 1.
however, only the data of the first webhook is transferred to the variables, see echoes in code section 1.

Triggered on event: storage.afterPropertyCreate name: a value: ["2"]
Triggered on event: storage.afterPropertyCreate name: c value: ["4"]
Triggered on event: storage.afterPropertyCreate name: b value: ["3"]
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on testnode in C:\workspace\tests\generic-webhook-trigger-test
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Print Trigger Source)
[Pipeline] echo
Triggered on event: storage.afterPropertyCreate by: a and ["2"]
[Pipeline] echo
Triggered on event: storage.afterPropertyCreate by: a and ["2"]
[Pipeline] echo
Triggered on event: storage.afterPropertyCreate by: a and ["2"]
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

the pipeline can be seen in fig 2.

pipeline {
    agent any

    triggers {
        GenericTrigger(
            genericVariables: [
                // expect data of 1. trigger source
                [key: 'EVENT_NAME',  value: '$.artifactory.webhook.event'],
                [key: 'ARTIFACT_NAME', value: '$.artifactory.webhook.data.name'],
                [key: 'ARTIFACT_VALUE', value: '$.artifactory.webhook.data.values[*]'],
                // expect data of 2. trigger source
                [key: 'EVENT_NAME1',  value: '$.artifactory.webhook.event'],
                [key: 'ARTIFACT_NAME1', value: '$.artifactory.webhook.data.name'],
                [key: 'ARTIFACT_VALUE1', value: '$.artifactory.webhook.data.values[*]'],
                // expect data of 3. trigger source
                [key: 'EVENT_NAME2',  value: '$.artifactory.webhook.event'],
                [key: 'ARTIFACT_NAME2', value: '$.artifactory.webhook.data.name'],
                [key: 'ARTIFACT_VALUE2', value: '$.artifactory.webhook.data.values[*]']
            ],
            causeString: 'Triggered on event: $EVENT_NAME name: $ARTIFACT_NAME value: $ARTIFACT_VALUE',
            token: 'abc1234',
    	    )
	}
    
    stages{
        stage('Print Trigger Source'){
            steps{
               echo "Triggered on event: ${EVENT_NAME} by: ${ARTIFACT_NAME} and ${ARTIFACT_VALUE}"
               echo "Triggered on event: ${EVENT_NAME1} by: ${ARTIFACT_NAME1} and ${ARTIFACT_VALUE1}"
               echo "Triggered on event: ${EVENT_NAME2} by: ${ARTIFACT_NAME2} and ${ARTIFACT_VALUE2}"
            }
        }
    }
}

How is it possible to access all data from the different webhooks?

@tomasbjerre
Copy link
Contributor

Not possible. But you can trigger 3 different jobs, one for each webhook.

You should get different jobs triggered if you make the job "parameterized" as described in the readme: https://github.com/jenkinsci/generic-webhook-trigger-plugin#default-values

See also #162

@saggl
Copy link
Author

saggl commented Jul 2, 2020

all right. thank you for your quick help

@saggl saggl closed this as completed Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants