Skip to content

Add support for Jenkins access token fixes #1423 #1425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()