Browse Source

Merge pull request #1425 from srp-gmbh/jenkins_access_token

Add support for Jenkins Git plugin access token,  fixes #1423
pull/1442/head
Florian Zschocke 1 year ago
parent
commit
83f8ee798f
No account linked to committer's email address
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      src/main/distrib/data/groovy/jenkins.groovy

+ 5
- 1
src/main/distrib/data/groovy/jenkins.groovy View File

@@ -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()

Loading…
Cancel
Save