Skip to content

Commit 83f8ee7

Browse files
authored
Merge pull request #1425 from srp-gmbh/jenkins_access_token
Add support for Jenkins Git plugin access token, fixes #1423
2 parents 7031f90 + 8e42836 commit 83f8ee7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/distrib/data/groovy/jenkins.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ logger.info("jenkins hook triggered by ${user.username} for ${repository.name}")
6969
// gitblit.properties or web.xml
7070
def jenkinsUrl = gitblit.getString('groovy.jenkinsServer', 'http://yourserver/jenkins')
7171

72+
// define your jenkins access token here or set groovy.jenkinsToken in
73+
// gitblit.properties or web.xml (https://github.com/jenkinsci/git-plugin/#push-notification-from-repository)
74+
def jenkinsToken = gitblit.getString('groovy.jenkinsToken', 'yourtoken')
75+
7276
// define the repository base url
7377
def jenkinsGitbaseurl = gitblit.getString('groovy.jenkinsGitbaseurl', "${url}/r")
7478

7579
// define the trigger url
76-
def triggerUrl = jenkinsUrl + "/git/notifyCommit?url=" + jenkinsGitbaseurl + "/${repository.name}"
80+
def triggerUrl = jenkinsUrl + "/git/notifyCommit?url=" + jenkinsGitbaseurl + "/${repository.name}" + "&token=" + jenkinsToken
7781

7882
// trigger the build
7983
new URL(triggerUrl).getContent()

0 commit comments

Comments
 (0)