This is a Jenkins plugin that can:
- Receive any HTTP POST request, http://JENKINS_URL/jenkins/generic-webhook-trigger/invoke
- Extract values with JSONPath or XPath
- Contribute those values as variables to the build
This means it can trigger on any webhook, like:
- Bitbucket Cloud
- Bitbucket Server
- GitHub
- GitLab
- Gogs
- Assembla
- An many many more!
The original use case was to build merge/pull requests. You may use the Git Plugin as described in this blog post to do that. There is also an example of this on the Violation Comments to GitLab Plugin page.
You may want to report back to the invoking system. HTTP Request Plugin is a very convenient plugin for that.
There are websites to help fiddle with the expressions. You may want to checkout this website to fiddle with JSONPath. And this website to fiddle with XPath.
Available in Jenkins here.
If you need the resolved values in pre build steps, like git clone, you need to add a parameter with the same name as the variable.
This plugin can be used with the Job DSL Plugin.
job('example genericTrigger') {
triggers {
genericTrigger {
genericVariables {
genericVariable {
key("variable")
value("JSONPath or XPath expression")
expressionType("JSONPath")
}
}
regexpFilterText("")
regexpFilterExpression("")
}
}
}
This plugin can be used with the Pipeline Plugin:
properties([
pipelineTriggers([
[$class: 'GenericTrigger',
genericVariables: [
[expressionType: 'JSONPath', key: 'variable1', value: 'expression1'],
[expressionType: 'JSONPath', key: 'variable2', value: 'expression2']
],
regexpFilterText: '',
regexpFilterExpression: ''
]
])
])
More details on Jenkins plugin development is available here.
There is a /build.sh
that will perform a full build and test the plugin. You may have a look at sandbox/settings.xml on how to configure your Maven settings.
A release is created like this. You need to clone from jenkinsci-repo, with https and have username/password in settings.xml.
mvn release:prepare release:perform