Jenkins Job Configuration: Webhook-Router
Prerequisites
- Generic Webhook Trigger Plugin >= 1.86.0 (required for
tokenCredentialIdsupport)- If using an older version, either upgrade the plugin or temporarily replace
tokenCredentialIdwithtokenin the Jenkinsfile
- If using an older version, either upgrade the plugin or temporarily replace
- Pipeline Plugin (standard Jenkins installation)
- Git Plugin (standard Jenkins installation)
Manual Configuration Steps (Jenkins UI)
Step 1: Create Webhook Token Credential
- Navigate to Jenkins: http://192.168.1.107:8080/credentials/
- Select the appropriate domain (or “Global”)
- Click “Add Credentials”
- Kind: Secret text
- Secret: Enter your chosen webhook token value (e.g., a random string)
- ID:
netbox-webhook-token - Description:
Token for NetBox webhook trigger - Click “Create”
This credential is referenced by
tokenCredentialIdin the Jenkinsfile.
The same token value must be configured in the NetBox Event Rule URL.
Step 2: Create New Pipeline Job
- Navigate to Jenkins: http://192.168.1.107:8080
- Click “New Item”
- Enter item name: Webhook-Router
- Select: Pipeline
- Click OK
Step 3: General Settings
- Description:
NetBox Webhook Router Pipeline - Routes VM/Device events to platform-specific pipelines - Discard old builds: ✅ Enabled
- Strategy: Log Rotation
- Days to keep builds: 30
- Max # of builds to keep: 50
Step 4: Build Triggers
⚠️ Important: Do NOT check “Generic Webhook Trigger” in the UI trigger section.
The trigger is configured inside the Jenkinsfile using the triggers {} block.
Step 5: Pipeline Configuration
- Definition: Pipeline script from SCM
- SCM: Git
- Repository URL:
git@github.com:blue126/IaC.git - Credentials: Select appropriate Git credentials
- Branches to build:
*/main(or your default branch) - Script Path:
Jenkinsfile-webhook-router
Step 6: Save Configuration
Click “Save” at the bottom of the page.
Verification Steps
Verify Job Exists
Verify Git Configuration
Trigger Manual Build
Jenkins Configuration as Code (JCasC)
If your Jenkins uses JCasC, add this to your jenkins.yaml:
Webhook URL
After job creation, the webhook endpoint will be:
Token authentication: The token should be sent via HTTP header (not URL query string) to avoid exposure in access logs and proxy logs.
NetBox Webhook configuration (Operations > Webhooks):
- URL:
http://192.168.1.107:8080/generic-webhook-trigger/invoke - Additional Headers:
token: <value-from-netbox-webhook-token-credential>
The token value is stored in Jenkins credential netbox-webhook-token (Step 1).
The Generic Webhook Trigger plugin accepts the token via header, query parameter, or Bearer token.
Troubleshooting
Problem: “No valid crumb was included in the request”
Solution: If using API, you need to include CSRF token:
Problem: Generic Webhook Trigger not firing
Solution:
- Ensure Generic Webhook Trigger plugin is installed
- Verify trigger configuration is in Jenkinsfile (not UI)
- Run job manually once to register the trigger
- Check Jenkins system log for webhook events
Problem: Cannot find Jenkinsfile
Solution:
- Verify Git repository is accessible from Jenkins
- Check Script Path is exactly:
Jenkinsfile-webhook-router - Ensure file is committed to the correct branch
- Trigger “Build Now” to force SCM poll