From 8e428360979a7c0e0b189370bd2b37ccb89e022d Mon Sep 17 00:00:00 2001 From: Tino Desjardins Date: Sat, 3 Sep 2022 08:45:36 +0200 Subject: [PATCH] Add support for Jenkins access token fixes #1423 --- src/main/distrib/data/groovy/jenkins.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/distrib/data/groovy/jenkins.groovy b/src/main/distrib/data/groovy/jenkins.groovy index f029b26a..7f88eb90 100644 --- a/src/main/distrib/data/groovy/jenkins.groovy +++ b/src/main/distrib/data/groovy/jenkins.groovy @@ -69,11 +69,15 @@ logger.info("jenkins hook triggered by ${user.username} for ${repository.name}") // gitblit.properties or web.xml def jenkinsUrl = gitblit.getString('groovy.jenkinsServer', 'http://yourserver/jenkins') +// define your jenkins access token here or set groovy.jenkinsToken in +// gitblit.properties or web.xml (https://github.com/jenkinsci/git-plugin/#push-notification-from-repository) +def jenkinsToken = gitblit.getString('groovy.jenkinsToken', 'yourtoken') + // define the repository base url def jenkinsGitbaseurl = gitblit.getString('groovy.jenkinsGitbaseurl', "${url}/r") // define the trigger url -def triggerUrl = jenkinsUrl + "/git/notifyCommit?url=" + jenkinsGitbaseurl + "/${repository.name}" +def triggerUrl = jenkinsUrl + "/git/notifyCommit?url=" + jenkinsGitbaseurl + "/${repository.name}" + "&token=" + jenkinsToken // trigger the build new URL(triggerUrl).getContent() -- 2.39.5