Skip to content

Commit

Permalink
Merge pull request gitblit-org#1425 from srp-gmbh/jenkins_access_token
Browse files Browse the repository at this point in the history
Add support for Jenkins Git plugin access token,  fixes gitblit-org#1423
  • Loading branch information
flaix authored Dec 9, 2022
2 parents 7031f90 + 8e42836 commit 83f8ee7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/distrib/data/groovy/jenkins.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 83f8ee7

Please sign in to comment.