elf
elf

Reputation: 67

The difference of token in build configuration and in jenkinsfile triggers block

Preconditions: Add a webhook in my repository:

http://JenkinsURL:Port/multibranch-webhook-trigger/invoke?token=myToken
  1. Go to Build Configuration -> Scan Multibranch Pipeline Trigger, Tick "Scan by webhook" and add "myToken" for "Trigger token"
    Push from repository -> build triggered -> work as expected
  2. Untick "Scan by webhook" from Build Configuration
    Add a trigger block like below
triggers {
    GenericTrigger(
        genericVariables:[
            //some variables
        ],
        token: 'myToken',
        //some configurations
    )
}
stages{
    // ...
}

Push from repository -> not build -> not expected behavior, seems token not work here

I wonder what the difference of these 2 tokens and how I should use token in jenkinsfile
I get the explations, see my answer below. If any one knows how we can use Multibranch webhook in triggers

Upvotes: 0

Views: 592

Answers (1)

elf
elf

Reputation: 67

I got the point: There're 2 webhook plugins:

  • Generic Webhook Trigger Plugin, receives any HTTP request as JENKINS_URL/generic-webhook-trigger/invoke?token=GenericToken. It can be used in Build Trigger in Freestyle project, Pipeline or other project... It also can be added in triggers block in jenkinsfile.
  • Multibranch Scan Webhook Trigger, receives any HTTP request as JENKINS_URL/multibranch-webhook-trigger/invoke?token=MultibranchToken and can be configured in Build Configuration in Multibranch Pipeline. I don't know if we can use Multibranch Scan Webhook Trigger in jenkinsfile.

Back to my question, I use Generic Webhook Trigger in triggers block, but send Multibranch webhook trigger from HTTP request. That's why it doesn't work.

Upvotes: 1

Related Questions