jenkinsci / generic-webhook-trigger-plugin

Can receive any HTTP request, extract any values from JSON or XML and trigger a job with those values available as variables. Works with GitHub, GitLab, Bitbucket, Jira and many more.
https://plugins.jenkins.io/generic-webhook-trigger
410 stars 162 forks source link

Pipeline is unable to configure itself #320

Closed skreienk closed 4 months ago

skreienk commented 4 months ago

Jenkins and plugins versions report

Jenkins version: 2.452.2 Plugin version: 2.21

We are setting up our instance of Jenkins under EKS kubernetes, with the seed jobs and all setup being created by the CASC plugin. One of the seed jobs creates the PIMRestore job, pointing to PIMRestore.pipeline, then triggers the first build of the job, which is important as the GenericTrigger config is contained within the pipeline. Here's the seed job snippet:

    pipelineJob(foldername + '/PIMRestore') {
            description('Nightly restore of PIM database.')
            displayName('PIMRestore')
            definition {
                    cpsScm {
                            scm {
                                    git {
                                            remote {
                                                    url("${GITHUB_GITOPS_REPO}")
                                                    credentials('git-jenkins')
                                            }
                                            branch('*/main')
                                    }
                            }
                            scriptPath("${PLATFORM_ITERATION}/${ENV_NAME}/pipelines/PIMRestore.pipeline")
                            lightweight(true)
                    }
            }
    }
    if (!jenkins.model.Jenkins.instance.getItemByFullName(foldername + '/PIMRestore')) {
            queue(foldername + '/PIMRestore')
    }

And here's the GenericTrigger snippet from the pipeline:

            GenericTrigger(
                    genericRequestVariables: [
                            [key: 'DRYRUN'],
                    ],
                    token: '${TOKEN}',
                    printContributedVariables: true,
                    printPostContent: true,
                    silentResponse: false,
                    causeString: "Triggered remotely",
            )

After the seed job triggers the first run of PIMRestore the GenericTrigger settings are visible when viewing the job configuration from the Jenkins UI, but they don't work. This is the response when calling the URL:

curl --max-time 30 -vks 'https://${JENKINS_URL}/generic-webhook-trigger/invoke?token=${TOKEN}&DRYRUN=false' (SSL INFO REMOVED FOR BREVITY) < HTTP/1.1 404 Not Found < Date: Wed, 03 Jul 2024 12:51:56 GMT < Content-Type: application/json;charset=utf-8 < Content-Length: 104 < Connection: keep-alive < X-Content-Type-Options: nosniff < Strict-Transport-Security: max-age=31536000; includeSubDomains < { [data not shown]

If I then go and view the configuration of the job in the UI and save it, without changing anything, the GenericTrigger plugin starts working:

curl --max-time 30 -vks 'https://${JENKINS_URL}/generic-webhook-trigger/invoke?token=${TOKEN}&DRYRUN=false' (SSL INFO REMOVED FOR BREVITY) < HTTP/1.1 200 OK < Date: Wed, 03 Jul 2024 14:11:54 GMT < Content-Type: application/json;charset=utf-8 < Content-Length: 185 < Connection: keep-alive < X-Content-Type-Options: nosniff < Strict-Transport-Security: max-age=31536000; includeSubDomains <

I don't understand why I have to view and save the job after it's created to make the GenericTrigger plugin see the config.

tomasbjerre commented 4 months ago

Can you double check if it really is Jenkins 2.452.2? It sounds a lot like #311 and #312

skreienk commented 4 months ago

I copied and pasted the version from the about screen in Jenkins. As this is under kubernetes I deleted the pod and associated PVC so that it would download and load everything from scratch. Version 2.452.2.

tomasbjerre commented 4 months ago

Possibly same as #319 .

skreienk commented 4 months ago

Any way to check?

tomasbjerre commented 4 months ago

No.

tomasbjerre commented 4 months ago

Closing this, I think it is same as #319.