Browse Source

Add Redmine Fetch groovy hook (issue-359)

tags/v1.4.0
Berke Viktor 10 years ago
parent
commit
0dfb9845d7
3 changed files with 71 additions and 0 deletions
  1. 1
    0
      build.xml
  2. 2
    0
      releases.moxie
  3. 68
    0
      src/main/distrib/data/groovy/redmine-fetch.groovy

+ 1
- 0
build.xml View File

@@ -958,6 +958,7 @@
<include name="fogbugz.groovy" />
<include name="thebuggenie.groovy" />
<include name="fisheye.groovy" />
<include name="redmine-fetch.groovy" />
</fileset>
</copy>
</sequential>

+ 2
- 0
releases.moxie View File

@@ -57,6 +57,7 @@ r20: {
- Added GO setting to automatically redirect all http requests to the secure https connector
- Automatically display common repository root documents as tabs on the docs page
- Support bugtraq configuration in collaboration with syntevo
- Added Redmine Fetch hook script (issue-359)
dependencyChanges:
- updated to Jetty 8.1.13
- updated to JGit 3.2.0
@@ -96,6 +97,7 @@ r20: {
- Alfred Schmid
- Gareth Collins
- Martijn van der Kleijn
- Berke Viktor
}

#

+ 68
- 0
src/main/distrib/data/groovy/redmine-fetch.groovy View File

@@ -0,0 +1,68 @@
/*
* Copyright 2014 Berke Viktor.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.gitblit.GitBlit
import com.gitblit.Keys
import com.gitblit.models.RepositoryModel
import com.gitblit.models.UserModel
import com.gitblit.utils.JGitUtils
import org.eclipse.jgit.lib.Repository
import org.slf4j.Logger
/*
* This script triggers automatic repo fetches in Redmine upon pushes.
* It won't work out-of-box, you need to configure a few things.
*
* Redmine
* - Go to Administration / Settings / Repositories, and make sure that the
* "Enable WS for repository management" option is checked. Also generate an
* API key and take note of it.
* - Open a project page, go to Settings / Repositories and add a repo. Take
* note of the Identifier.
*
* Gitblit
* - Set the redmineProject custom field in gitblit.properties, e.g.
* groovy.customFields = "redmineProject=Redmine Project Identifier"
* - Edit the repo you added to Redmine, go to hook scripts and add this script
* to the post-receive hooks. Also specify the Redmine project's identifier
* under custom fields.
*
* Troubleshooting
* - run Gitblit interactively and check its console output
* - on the Redmine server, tail -f log/access.log
*
* If you want your repos to work with multiple Redmine projects, you don't need
* to add the repos to all of them. Instead, add the repo to a single project,
* then go to Administration / Settings / Repositories and enable the "Allow
* issues of all the other projects to be referenced and fixed" option.
*/
/* specify the URL of your Redmine instance here */
def redmineURL = "http://redmine.foo.bar/"
/* specify the API key you generated in Redmine Administration here */
def apiKey = "FIXME"
/*
* construct the URL from global and repo properties, for more info refer to
* http://www.redmine.org/projects/redmine/wiki/RedmineSettings#Fetch-commits-automatically
*/
def triggerURL = redmineURL + "sys/fetch_changesets?id=" + repository.customFields.redmineProject + "&key=" + apiKey
/* log the action */
logger.info("Redmine Fetch hook triggered by ${user.username} for ${repository.name}: GET ${triggerURL}")
/* send the HTTP GET query */
new URL(triggerURL).getContent()

Loading…
Cancel
Save