/deploy\r
/*.jks\r
/x509test\r
-/certs
\ No newline at end of file
+/certs
+/data
<property name="project.jar" value="gitblit.jar" />\r
<property name="project.mainclass" value="com.gitblit.Launcher" />\r
<property name="project.build.dir" value="${basedir}/build" />\r
- <property name="project.deploy.dir" value="${basedir}/deploy" />\r
+ <property name="project.deploy.dir" value="${basedir}/deploy" /> \r
<property name="project.war.dir" value="${basedir}/war" />\r
<property name="project.jar.dir" value="${basedir}/jar" />\r
- <property name="project.site.dir" value="${basedir}/site" />\r
+ <property name="project.site.dir" value="${basedir}/target/site" />\r
+ <property name="project.target.dir" value="${basedir}/target" />\r
<property name="project.resources.dir" value="${basedir}/resources" /> \r
<property name="project.express.dir" value="${basedir}/express" />\r
<property name="project.maven.repo.url" value="enter here your Maven repo URL" />\r
-->\r
<target name="compile" depends="buildinfo" description="Retrieves dependencies and compiles Gitblit from source">\r
\r
- <!-- copy required distribution files to project folder -->\r
- <copy todir="${basedir}" overwrite="false">\r
+ <!-- cleanup old builds -->\r
+ <delete dir="${project.target.dir}" />\r
+ <mkdir dir="${project.target.dir}" />\r
+ \r
+ <!-- cleanup old builds -->\r
+ <delete>\r
+ <fileset dir="${basedir}">\r
+ <include name="*.zip" />\r
+ <include name="*.war" />\r
+ <include name="*.jar" />\r
+ </fileset>\r
+ </delete>\r
+ \r
+ <!-- copy required distribution files to data folder -->\r
+ <mkdir dir="${basedir}/data" />\r
+ <copy todir="${basedir}/data" overwrite="false">\r
<fileset dir="${basedir}/distrib">\r
<include name="gitblit.properties" />\r
<include name="users.conf" />\r
+ <include name="projects.conf" />\r
</fileset>\r
</copy>\r
\r
<!-- copy required distribution files to project folder -->\r
- <mkdir dir="${basedir}/certs" />\r
- <copy todir="${basedir}/certs" overwrite="false">\r
+ <mkdir dir="${basedir}/data/certs" />\r
+ <copy todir="${basedir}/data/certs" overwrite="false">\r
<fileset dir="${basedir}/distrib">\r
<include name="authority.conf" />\r
<include name="*.tmpl" />\r
</fileset>\r
</copy>\r
+ \r
+ <!-- copy required distribution files to project folder -->\r
+ <mkdir dir="${basedir}/data/groovy" />\r
+ <copy todir="${basedir}/data/groovy" overwrite="false">\r
+ <fileset dir="${basedir}/distrib/groovy" />\r
+ </copy>\r
+ \r
+ <!-- upgrade existing workspace to data folder -->\r
+ <move todir="${basedir}/data" overwrite="true" failonerror="false">\r
+ <fileset dir="${basedir}">\r
+ <include name="users.conf" />\r
+ <include name="projects.conf" />\r
+ <include name="gitblit.properties" />\r
+ <include name="serverKeyStore.jks" />\r
+ <include name="serverTrustStore.jks" />\r
+ </fileset>\r
+ </move>\r
+ <move todir="${basedir}/data/certs" overwrite="true" failonerror="false">\r
+ <fileset dir="${basedir}/certs" />\r
+ </move>\r
+ <move todir="${basedir}/data/git" overwrite="true" failonerror="false">\r
+ <fileset dir="${basedir}/git" />\r
+ </move>\r
+ <move todir="${basedir}/data/proposals" overwrite="true" failonerror="false">\r
+ <fileset dir="${basedir}/proposals" />\r
+ </move>\r
+ <delete dir="${basedir}/javadoc" failonerror="false" />\r
+ <delete dir="${basedir}/site" failonerror="false" />\r
+ <delete dir="${basedir}/temp" failonerror="false" />\r
\r
<!-- copy gitblit.properties to the WEB-INF folder.\r
this file is only used for parsing setting descriptions. -->\r
<exclude name="federation.properties" />\r
<exclude name="openshift.mkd" />\r
<exclude name="authority.conf" />\r
+ <exclude name="users.conf" />\r
+ <exclude name="projects.conf" />\r
+ <exclude name="gitblit.properties" />\r
<exclude name="*.tmpl" />\r
+ <exclude name="groovy/**" />\r
</fileset>\r
<fileset dir="${basedir}">\r
<include name="LICENSE" />\r
<include name="NOTICE" />\r
</fileset> \r
</copy>\r
- <copy tofile="${project.deploy.dir}/authority.jar" file="${basedir}/authority-${gb.version}.jar" />\r
\r
+ <!-- Copy the supported Groovy hook scripts -->\r
+ <mkdir dir="${project.deploy.dir}/data/groovy" />\r
+ <copy todir="${project.deploy.dir}/data/groovy">\r
+ <fileset dir="${basedir}/distrib/groovy">\r
+ <include name="sendmail.groovy" />\r
+ <include name="sendmail-html.groovy" />\r
+ <include name="jenkins.groovy" />\r
+ <include name="protect-refs.groovy" />\r
+ </fileset>\r
+ </copy>\r
+ \r
+ <copy tofile="${project.deploy.dir}/authority.jar" file="${project.target.dir}/authority-${gb.version}.jar" />\r
+ \r
+ <!-- Prepare the data folder -->\r
+ <mkdir dir="${project.deploy.dir}/data"/>\r
+ <copy todir="${project.deploy.dir}/data">\r
+ <fileset dir="${basedir}/distrib">\r
+ <include name="users.conf" />\r
+ <include name="projects.conf" />\r
+ <include name="gitblit.properties" />\r
+ </fileset>\r
+ </copy>\r
+ \r
<!-- Certificate templates -->\r
- <mkdir dir="${project.deploy.dir}/certs"/>\r
- <copy todir="${project.deploy.dir}/certs">\r
+ <mkdir dir="${project.deploy.dir}/data/certs"/>\r
+ <mkdir dir="${project.deploy.dir}/data/certs"/>\r
+ <copy todir="${project.deploy.dir}/data/certs">\r
<fileset dir="${basedir}/distrib">\r
<include name="*.tmpl" />\r
<include name="authority.conf" />\r
<param name="docs.output.dir" value="${project.deploy.dir}/docs" />\r
</antcall>\r
\r
- <!-- Copy the supported Groovy hook scripts -->\r
- <mkdir dir="${project.deploy.dir}/groovy" />\r
- <copy todir="${project.deploy.dir}/groovy">\r
- <fileset dir="${basedir}/groovy">\r
- <include name="sendmail.groovy" />\r
- <include name="sendmail-html.groovy" />\r
- <include name="jenkins.groovy" />\r
- <include name="protect-refs.groovy" />\r
- <include name="localclone.groovy" />\r
- </fileset>\r
- </copy>\r
- \r
<!-- Create Zip deployment --> \r
- <zip destfile="${distribution.zipfile}">\r
+ <zip destfile="${project.target.dir}/${distribution.zipfile}">\r
<fileset dir="${project.deploy.dir}">\r
<include name="**/*" />\r
</fileset>\r
\r
<!-- Copy web.xml and users.conf to WEB-INF -->\r
<copy todir="${project.war.dir}/WEB-INF">\r
- <fileset dir="${basedir}/distrib">\r
- <include name="users.conf" />\r
- </fileset>\r
<fileset dir="${basedir}/src/WEB-INF">\r
<include name="web.xml" />\r
</fileset>\r
<param name="docs.output.dir" value="${project.war.dir}/WEB-INF/docs" />\r
</antcall>\r
\r
+ <!-- Copy users.conf to WEB-INF/data -->\r
+ <mkdir dir="${project.war.dir}/WEB-INF/data" />\r
+ <copy todir="${project.war.dir}/WEB-INF/data">\r
+ <fileset dir="${basedir}/distrib">\r
+ <include name="users.conf" />\r
+ <include name="projects.conf" />\r
+ <include name="gitblit.properties" />\r
+ </fileset>\r
+ </copy>\r
+\r
<!-- Copy the supported Groovy hook scripts -->\r
- <mkdir dir="${project.war.dir}/WEB-INF/groovy" />\r
- <copy todir="${project.war.dir}/WEB-INF/groovy">\r
- <fileset dir="${basedir}/groovy">\r
+ <mkdir dir="${project.war.dir}/WEB-INF/data/groovy" />\r
+ <copy todir="${project.war.dir}/WEB-INF/data/groovy">\r
+ <fileset dir="${basedir}/distrib/groovy">\r
<include name="sendmail.groovy" />\r
<include name="sendmail-html.groovy" />\r
<include name="jenkins.groovy" />\r
<include name="protect-refs.groovy" />\r
- <include name="localclone.groovy" />\r
</fileset>\r
</copy>\r
\r
- <!-- Build the WAR web.xml from the prototype web.xml and gitblit.properties --> \r
+ <!-- Build the WAR web.xml from the prototype web.xml --> \r
<java classpath="${project.build.dir}" classname="com.gitblit.build.BuildWebXml">\r
<classpath refid="master-classpath" />\r
\r
<arg value="--destinationFile" />\r
<arg value="${project.war.dir}/WEB-INF/web.xml" />\r
\r
- <arg value="--propertiesFile" />\r
- <arg value="${basedir}/distrib/gitblit.properties" />\r
</java>\r
\r
<!-- Gitblit resources -->\r
</copy>\r
\r
<!-- Build the WAR file -->\r
- <jar basedir="${project.war.dir}" destfile="${distribution.warfile}" compress="true" />\r
+ <jar basedir="${project.war.dir}" destfile="${project.target.dir}/${distribution.warfile}" compress="true" />\r
</target>\r
\r
\r
<target name="buildFederationClient" depends="compile" description="Builds the stand-alone Gitblit federation client">\r
<echo>Building Gitblit Federation Client ${gb.version}</echo>\r
\r
- <genjar jarfile="fedclient.jar">\r
+ <genjar jarfile="${project.target.dir}/fedclient.jar">\r
<class name="com.gitblit.FederationClientLauncher" />\r
<resource file="${project.build.dir}/log4j.properties" />\r
<classfilter>\r
</genjar>\r
\r
<!-- Build the federation client zip file -->\r
- <zip destfile="${fedclient.zipfile}">\r
+ <zip destfile="${project.target.dir}/${fedclient.zipfile}">\r
<fileset dir="${basedir}">\r
- <include name="fedclient.jar" />\r
<include name="LICENSE" />\r
<include name="NOTICE" />\r
</fileset>\r
+ <fileset dir="${project.target.dir}">\r
+ <include name="fedclient.jar" />\r
+ </fileset>\r
<fileset dir="${basedir}/distrib">\r
<include name="federation.properties" />\r
</fileset>\r
</zip>\r
+ \r
+ <!-- Cleanup -->\r
+ <delete file="${project.target.dir}/fedclient.jar" />\r
</target>\r
\r
\r
<copy tofile="${deployments.root}/WEB-INF/reference.properties" \r
file="${basedir}/distrib/gitblit.properties"/>\r
\r
+ <!-- Copy users.conf and gitblit.properties -->\r
+ <mkdir dir="${deployments.root}/WEB-INF/data" />\r
+ <copy todir="${deployments.root}/WEB-INF/data">\r
+ <fileset dir="${basedir}/distrib">\r
+ <include name="users.conf" />\r
+ <include name="projects.conf" />\r
+ <include name="gitblit.properties" />\r
+ </fileset>\r
+ </copy>\r
+ \r
<!-- Copy the supported Groovy hook scripts -->\r
- <mkdir dir="${deployments.root}/WEB-INF/groovy" />\r
- <copy todir="${deployments.root}/WEB-INF/groovy">\r
- <fileset dir="${basedir}/groovy">\r
+ <mkdir dir="${deployments.root}/WEB-INF/data/groovy" />\r
+ <copy todir="${deployments.root}/WEB-INF/data/groovy">\r
+ <fileset dir="${basedir}/distrib/groovy">\r
<include name="sendmail.groovy" />\r
<include name="sendmail-html.groovy" />\r
<include name="jenkins.groovy" />\r
<exclude name="hamcrest*.jar" />\r
<exclude name="servlet*.jar" />\r
<exclude name="javax.servlet*.jar" />\r
+ <exclude name="jsslutils*.jar" />\r
+ <exclude name="jcalendar*.jar" />\r
</fileset>\r
</copy>\r
\r
</jar>\r
\r
<!-- Build Express Zip file -->\r
- <zip destfile="${express.zipfile}">\r
+ <zip destfile="${project.target.dir}/${express.zipfile}">\r
<fileset dir="${project.express.dir}" />\r
</zip>\r
\r
<target name="buildManager" depends="compile" description="Builds the stand-alone Gitblit Manager">\r
<echo>Building Gitblit Manager ${gb.version}</echo>\r
\r
- <genjar jarfile="manager-${gb.version}.jar">\r
+ <genjar jarfile="${project.target.dir}/manager-${gb.version}.jar">\r
<resource file="${basedir}/src/com/gitblit/client/splash.png" />\r
<resource file="${basedir}/resources/gitblt-favicon.png" />\r
<resource file="${basedir}/resources/gitweb-favicon.png" />\r
</genjar>\r
\r
<!-- Build Manager Zip file -->\r
- <zip destfile="${manager.zipfile}">\r
+ <zip destfile="${project.target.dir}/${manager.zipfile}">\r
<fileset dir="${basedir}">\r
- <include name="manager-${gb.version}.jar" />\r
<include name="LICENSE" />\r
<include name="NOTICE" />\r
</fileset>\r
+ <fileset dir="${project.target.dir}">\r
+ <include name="manager-${gb.version}.jar" />\r
+ </fileset>\r
</zip>\r
+ \r
+ <!-- Cleanup -->\r
+ <delete file="${project.target.dir}/manager-${gb.version}.jar" />\r
</target>\r
\r
\r
<target name="buildAuthority" depends="compile" description="Builds the stand-alone Gitblit Authority">\r
<echo>Building Gitblit Authority ${gb.version}</echo>\r
\r
- <genjar jarfile="authority-${gb.version}.jar">\r
+ <genjar jarfile="${project.target.dir}/authority-${gb.version}.jar">\r
<resource file="${basedir}/src/com/gitblit/client/splash.png" />\r
<resource file="${basedir}/resources/gitblt-favicon.png" />\r
<resource file="${basedir}/resources/user_16x16.png" />\r
</genjar>\r
\r
<!-- Build Authority Zip file -->\r
- <zip destfile="${authority.zipfile}">\r
+ <zip destfile="${project.target.dir}/${authority.zipfile}">\r
<fileset dir="${basedir}">\r
- <include name="authority-${gb.version}.jar" />\r
<include name="LICENSE" />\r
<include name="NOTICE" />\r
</fileset>\r
- <zipfileset dir="${basedir}/distrib" prefix="certs">\r
+ <fileset dir="${project.target.dir}">\r
+ <include name="authority-${gb.version}.jar" />\r
+ </fileset>\r
+ <zipfileset dir="${basedir}/distrib" prefix="data/certs">\r
<include name="authority.conf" />\r
<include name="mail.tmpl" />\r
<include name="instructions.tmpl" />\r
<echo>Building Gitblit API Library ${gb.version}</echo>\r
\r
<!-- Build API Library jar -->\r
- <genjar jarfile="gbapi-${gb.version}.jar">\r
+ <genjar jarfile="${project.target.dir}/gbapi-${gb.version}.jar">\r
<class name="com.gitblit.Keys" />\r
<class name="com.gitblit.client.GitblitClient" />\r
<classpath refid="master-classpath" />\r
</genjar>\r
\r
<!-- Build API sources jar -->\r
- <zip destfile="gbapi-${gb.version}-sources.jar">\r
+ <zip destfile="${project.target.dir}/gbapi-${gb.version}-sources.jar">\r
<fileset dir="${basedir}/src" defaultexcludes="yes">\r
<include name="com/gitblit/Constants.java"/>\r
<include name="com/gitblit/GitBlitException.java"/>\r
</zip>\r
\r
<!-- Build API JavaDoc jar -->\r
- <javadoc destdir="${basedir}/javadoc">\r
+ <javadoc destdir="${project.target.dir}/javadoc">\r
<fileset dir="${basedir}/src" defaultexcludes="yes">\r
<include name="com/gitblit/Constants.java"/>\r
<include name="com/gitblit/GitBlitException.java"/>\r
<include name="com/gitblit/utils/**/*.java"/> \r
</fileset>\r
</javadoc>\r
- <zip destfile="gbapi-${gb.version}-javadoc.jar">\r
- <fileset dir="${basedir}/javadoc" />\r
+ <zip destfile="${project.target.dir}/gbapi-${gb.version}-javadoc.jar">\r
+ <fileset dir="${project.target.dir}/javadoc" />\r
</zip>\r
\r
<!-- Build the API library zip file -->\r
- <zip destfile="${gbapi.zipfile}">\r
+ <zip destfile="${project.target.dir}/${gbapi.zipfile}">\r
<fileset dir="${basedir}">\r
+ <include name="LICENSE" />\r
+ <include name="NOTICE" />\r
+ </fileset>\r
+ <fileset dir="${project.target.dir}">\r
<include name="gbapi-${gb.version}.jar" />\r
<include name="gbapi-${gb.version}-sources.jar" />\r
<include name="gbapi-${gb.version}-javadoc.jar" />\r
- <include name="LICENSE" />\r
- <include name="NOTICE" />\r
</fileset>\r
<fileset dir="${basedir}/ext">\r
<exclude name="src/**" />\r
<include name="jdom*.jar" />\r
</fileset>\r
</zip>\r
+ \r
+ <!-- Cleanup -->\r
+ <delete>\r
+ <fileset dir="${project.target.dir}">\r
+ <include name="javadoc/**" />\r
+ <include name="gbapi-${gb.version}.jar" />\r
+ <include name="gbapi-${gb.version}-sources.jar" />\r
+ <include name="gbapi-${gb.version}-javadoc.jar" />\r
+ </fileset>\r
+ </delete>\r
</target>\r
\r
\r
-@java -jar authority.jar\r
+@java -jar authority.jar --baseFolder data\r
set -e
GITBLIT_PATH=/opt/gitblit
+GITBLIT_BASE_FOLDER=/opt/gitblit/data
GITBLIT_HTTP_PORT=0
GITBLIT_HTTPS_PORT=8443
source ${GITBLIT_PATH}/java-proxy-config.sh
start)
log_action_begin_msg "Starting gitblit server"
cd $GITBLIT_PATH
- $JAVA $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT > /dev/null &
+ $JAVA $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT --baseFolder $GITBLIT_BASE_FOLDER > /dev/null &
log_action_end_msg $?
;;
stop)
log_action_begin_msg "Stopping gitblit server"
cd $GITBLIT_PATH
- $JAVA $GITBLIT_PATH/gitblit.jar --stop > /dev/null &
+ $JAVA $GITBLIT_PATH/gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER --stop > /dev/null &
log_action_end_msg $?
;;
force-reload|restart)
# change theses values (default values)
GITBLIT_PATH=/opt/gitblit
+GITBLIT_BASE_FOLDER=/opt/gitblit/data
GITBLIT_HTTP_PORT=0
GITBLIT_HTTPS_PORT=8443
source ${GITBLIT_PATH}/java-proxy-config.sh
then
echo $"Starting gitblit server"
cd $GITBLIT_PATH
- $JAVA $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT > /dev/null &
+ $JAVA $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT --baseFolder $GITBLIT_BASE_FOLDER > /dev/null &
echo "."
exit $RETVAL
fi
then
echo $"Stopping gitblit server"
cd $GITBLIT_PATH
- $JAVA $GITBLIT_PATH/gitblit.jar --stop > /dev/null &
+ $JAVA $GITBLIT_PATH/gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER --stop > /dev/null &
echo "."
exit $RETVAL
fi
-@java -jar gitblit.jar --stop\r
+@java -jar gitblit.jar --stop --baseFolder data\r
# change theses values (default values)
GITBLIT_PATH=/opt/gitblit
+GITBLIT_BASE_FOLDER=/opt/gitblit/data
GITBLIT_USER="gitblit"
source ${GITBLIT_PATH}/java-proxy-config.sh
-ARGS="-server -Xmx1024M ${JAVA_PROXY_CONFIG} -Djava.awt.headless=true -jar gitblit.jar"
+ARGS="-server -Xmx1024M ${JAVA_PROXY_CONFIG} -Djava.awt.headless=true -jar gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER"
RETVAL=0
-@java -jar gitblit.jar\r
+@java -jar gitblit.jar --baseFolder data\r
#\r
+# Gitblit Settings\r
+#\r
+\r
+# This settings file supports parameterization from the command-line for the\r
+# following command-line parameters:\r
+#\r
+# --baseFolder ${baseFolder} SINCE 1.2.1\r
+#\r
+# Settings that support ${baseFolder} parameter substitution are indicated with the\r
+# BASEFOLDER attribute. If the --baseFolder argument is unspecified, ${baseFolder}\r
+# and it's trailing / will be discarded from the setting value leaving a relative\r
+# path that is equivalent to pre-1.2.1 releases.\r
+#\r
+# e.g. "${baseFolder}/git" becomes "git", if --baseFolder is unspecified \r
+#\r
# Git Servlet Settings\r
#\r
\r
#\r
# SINCE 0.5.0\r
# RESTART REQUIRED\r
-git.repositoriesFolder = git\r
+# BASEFOLDER\r
+git.repositoriesFolder = ${baseFolder}/git\r
\r
# Build the available repository list at startup and cache this list for reuse.\r
# This reduces disk io when presenting the repositories page, responding to rpcs,\r
#\r
# RESTART REQUIRED\r
# SINCE 0.8.0\r
-groovy.scriptsFolder = groovy\r
+# BASEFOLDER\r
+groovy.scriptsFolder = ${baseFolder}/groovy\r
\r
# Specify the directory Grape uses for downloading libraries.\r
# http://groovy.codehaus.org/Grape\r
#\r
# RESTART REQUIRED\r
# SINCE 1.0.0\r
-groovy.grapeFolder = groovy/grape\r
+# BASEFOLDER\r
+groovy.grapeFolder = ${baseFolder}/groovy/grape\r
\r
# Scripts to execute on Pre-Receive.\r
#\r
# Config file for storing project metadata\r
#\r
# SINCE 1.2.0\r
-web.projectsFile = projects.conf\r
+# BASEFOLDER\r
+web.projectsFile = ${baseFolder}/projects.conf\r
\r
# Either the full path to a user config file (users.conf)\r
# OR the full path to a simple user properties file (users.properties)\r
#\r
# SINCE 0.5.0\r
# RESTART REQUIRED\r
-realm.userService = users.conf\r
+# BASEFOLDER\r
+realm.userService = ${baseFolder}/users.conf\r
\r
# How to store passwords.\r
# Valid values are plain, md5, or combined-md5. md5 is the hash of password.\r
# http://googlewebmastercentral.blogspot.com/2008/06/improving-on-robots-exclusion-protocol.html\r
#\r
# SINCE 1.0.0\r
-web.robots.txt = \r
+# BASEFOLDER\r
+web.robots.txt = ${baseFolder}/robots.txt\r
\r
# If true, the web ui layout will respond and adapt to the browser's dimensions.\r
# if false, the web ui will use a 940px fixed-width layout.\r
# Specifying "gitblit" uses the internal login message.\r
#\r
# SINCE 0.7.0\r
+# BASEFOLDER\r
web.loginMessage = gitblit\r
\r
# This is the message displayed above the repositories table.\r
# Specifying "gitblit" uses the internal welcome message.\r
#\r
# SINCE 0.5.0\r
+# BASEFOLDER\r
web.repositoriesMessage = gitblit\r
\r
# Ordered list of charsets/encodings to use when trying to display a blob.\r
# Use forward slashes even on Windows!!\r
#\r
# SINCE 0.6.0\r
-federation.proposalsFolder = proposals\r
+# BASEFOLDER\r
+federation.proposalsFolder = ${baseFolder}/proposals\r
\r
# The default pull frequency if frequency is unspecified on a registration\r
#\r
#\r
# SINCE 1.0.0\r
# RESTART REQUIRED\r
-realm.ldap.backingUserService = users.conf\r
+# BASEFOLDER\r
+realm.ldap.backingUserService = ${baseFolder}/users.conf\r
\r
# Delegate team membership control to LDAP.\r
#\r
# default: users.conf\r
#\r
# RESTART REQUIRED\r
-realm.redmine.backingUserService = users.conf\r
+# BASEFOLDER\r
+realm.redmine.backingUserService = ${baseFolder}/users.conf\r
\r
# URL of the Redmine.\r
realm.redmine.url = http://example.com/redmine\r
#\r
# SINCE 0.5.0\r
# RESTART REQUIRED\r
-server.tempFolder = temp\r
+# BASEFOLDER\r
+server.tempFolder = ${baseFolder}/temp\r
\r
# Use Jetty NIO connectors. If false, Jetty Socket connectors will be used.\r
#\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import java.text.MessageFormat;\r
+\r
+import com.gitblit.GitBlit\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.UserModel\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+import com.gitblit.utils.ClientLogger\r
+\r
+/**\r
+ * Sample Gitblit Pre-Receive Hook: blockpush\r
+ * \r
+ * This script could and perhaps should be further developed to provide\r
+ * a full repository-branch permissions system similar to gitolite or gitosis.\r
+ *\r
+ * The Pre-Receive hook is executed after an incoming push has been parsed,\r
+ * validated, and objects have been written but BEFORE the refs are updated.\r
+ * This is the appropriate point to block a push for some reason.\r
+ *\r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.preReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push. If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ * \r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ *\r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ * \r
+ * If you want this hook script to fail and abort all subsequent scripts in the\r
+ * chain, "return false" at the appropriate failure points.\r
+ *\r
+ * Bound Variables:\r
+ * gitblit Gitblit Server com.gitblit.GitBlit\r
+ * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
+ * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
+ * user Gitblit User com.gitblit.models.UserModel\r
+ * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ * url Base url for Gitblit String\r
+ * logger Logs messages to Gitblit org.slf4j.Logger\r
+ * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ * def myCustomField = repository.customFields.myCustomField\r
+ * \r
+ */\r
+\r
+// Indicate we have started the script\r
+logger.info("blockpush hook triggered by ${user.username} for ${repository.name}: checking ${commands.size} commands")\r
+\r
+/*\r
+ * Example rejection of pushes to the master branch of example.git\r
+ */\r
+def blocked = false\r
+switch (repository.name) {\r
+ case 'ex@mple.git':\r
+ for (ReceiveCommand command : commands) {\r
+ def updatedRef = command.refName\r
+ if (updatedRef.equals('refs/heads/master')) {\r
+ // to reject a command set it's result to anything other than Result.NOT_ATTEMPTED\r
+ command.setResult(Result.REJECTED_OTHER_REASON, "You are not permitted to write to ${repository.name}:${updatedRef}")\r
+ blocked = true\r
+ }\r
+ }\r
+ break\r
+\r
+ default:\r
+ break\r
+}\r
+\r
+if (blocked) {\r
+ // return false to break the push hook chain\r
+ return false\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+\r
+/**\r
+ * Sample Gitblit Post-Receive Hook: jenkins\r
+ *\r
+ * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
+ * to the Git repository. This is the appropriate point to trigger an\r
+ * integration build or to send a notification.\r
+ * \r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push. If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ *\r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ * \r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ * \r
+ * Bound Variables:\r
+ * gitblit Gitblit Server com.gitblit.GitBlit\r
+ * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
+ * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
+ * user Gitblit User com.gitblit.models.UserModel\r
+ * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ * url Base url for Gitblit String\r
+ * logger Logs messages to Gitblit org.slf4j.Logger\r
+ * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ * def myCustomField = repository.customFields.myCustomField\r
+ * \r
+ */\r
+// Indicate we have started the script\r
+logger.info("jenkins hook triggered by ${user.username} for ${repository.name}")\r
+\r
+// This script requires Jenkins Git plugin 1.1.14 or later\r
+// http://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/\r
+\r
+// define your jenkins url here or set groovy.jenkinsServer in \r
+// gitblit.properties or web.xml\r
+def jenkinsUrl = gitblit.getString('groovy.jenkinsServer', 'http://yourserver/jenkins')\r
+\r
+// define the trigger url\r
+def triggerUrl = jenkinsUrl + "/git/notifyCommit?url=$url/git/$repository.name"\r
+\r
+// trigger the build\r
+new URL(triggerUrl).getContent()\r
--- /dev/null
+/*\r
+ * Copyright 2012 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.TeamModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import com.gitblit.utils.StringUtils\r
+import java.text.SimpleDateFormat\r
+import org.eclipse.jgit.api.CloneCommand\r
+import org.eclipse.jgit.api.Git\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.lib.Config\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.eclipse.jgit.util.FileUtils\r
+import org.slf4j.Logger\r
+\r
+/**\r
+ * Sample Gitblit Post-Receive Hook: localclone\r
+ *\r
+ * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
+ * to the Git repository. This is the appropriate point to trigger an\r
+ * integration build or to send a notification.\r
+ * \r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push. If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ *\r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ * \r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ *\r
+ * If you want this hook script to fail and abort all subsequent scripts in the\r
+ * chain, "return false" at the appropriate failure points.\r
+ * \r
+ * Bound Variables:\r
+ * gitblit Gitblit Server com.gitblit.GitBlit\r
+ * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
+ * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
+ * user Gitblit User com.gitblit.models.UserModel\r
+ * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ * url Base url for Gitblit String\r
+ * logger Logs messages to Gitblit org.slf4j.Logger\r
+ * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ * def myCustomField = repository.customFields.myCustomField\r
+ * \r
+ */\r
+\r
+// Indicate we have started the script\r
+logger.info("localclone hook triggered by ${user.username} for ${repository.name}")\r
+\r
+def rootFolder = 'c:/test'\r
+def bare = false\r
+def cloneAllBranches = true\r
+def cloneBranch = 'refs/heads/master'\r
+def includeSubmodules = true\r
+\r
+def repoName = repository.name\r
+def destinationFolder = new File(rootFolder, StringUtils.stripDotGit(repoName))\r
+def srcUrl = 'file://' + new File(GitBlit.getRepositoriesFolder(), repoName).absolutePath\r
+\r
+// delete any previous clone\r
+if (destinationFolder.exists()) {\r
+ FileUtils.delete(destinationFolder, FileUtils.RECURSIVE)\r
+}\r
+\r
+// clone the repository\r
+logger.info("cloning ${srcUrl} to ${destinationFolder}")\r
+CloneCommand cmd = Git.cloneRepository();\r
+cmd.setBare(bare)\r
+if (cloneAllBranches)\r
+ cmd.setCloneAllBranches(true)\r
+else\r
+ cmd.setBranch(cloneBranch)\r
+cmd.setCloneSubmodules(includeSubmodules)\r
+cmd.setURI(srcUrl)\r
+cmd.setDirectory(destinationFolder)\r
+Git git = cmd.call();\r
+git.repository.close()\r
+\r
+// report clone operation success back to pushing Git client\r
+clientLogger.info("${repoName} cloned to ${destinationFolder}")
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright 2012 Philip L. McMahon.\r
+ *\r
+ * Derived from blockpush.groovy, copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.UserModel\r
+\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+\r
+/**\r
+ * Sample Gitblit Pre-Receive Hook: protect-refs\r
+ * \r
+ * This script provides basic authorization of receive command types for a list\r
+ * of known ref patterns. Command types and unmatched ref patterns will be\r
+ * ignored, meaning this script has an "allow by default" policy.\r
+ *\r
+ * This script works best when a repository requires authentication on push, but\r
+ * can be used to enforce fast-forward commits or prohibit ref deletion by\r
+ * setting the *authorizedTeams* variable to an empty list and adding a ".+"\r
+ * entry to the *protectedRefs* list.\r
+ *\r
+ * The Pre-Receive hook is executed after an incoming push has been parsed,\r
+ * validated, and objects have been written but BEFORE the refs are updated.\r
+ * This is the appropriate point to block a push for some reason.\r
+ *\r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.preReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push. If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ * \r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ *\r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ * \r
+ * This script may reject one or more commands, but will never return false.\r
+ * Subsequent scripts, if any, will always be invoked.\r
+ *\r
+ * Bound Variables:\r
+ * gitblit Gitblit Server com.gitblit.GitBlit\r
+ * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
+ * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
+ * user Gitblit User com.gitblit.models.UserModel\r
+ * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ * url Base url for Gitblit String\r
+ * logger Logs messages to Gitblit org.slf4j.Logger\r
+ * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ * def myCustomField = repository.customFields.myCustomField\r
+ * \r
+ */\r
+\r
+// map of protected command types to returned results type\r
+// commands not included will skip authz check\r
+def protectedCmds = [\r
+ UPDATE_NONFASTFORWARD: Result.REJECTED_NONFASTFORWARD,\r
+ DELETE: Result.REJECTED_NODELETE\r
+]\r
+\r
+// list of regex patterns for protected refs\r
+def protectedRefs = [\r
+ "refs/heads/master",\r
+ "refs/tags/.+"\r
+]\r
+\r
+// teams which are authorized to perform protected commands on protected refs\r
+def authorizedTeams = [ "admins" ]\r
+\r
+for (ReceiveCommand command : commands) {\r
+ def updateType = command.type\r
+ def updatedRef = command.refName\r
+ \r
+ // find first regex which matches updated ref, if any\r
+ def refPattern = protectedRefs.find { updatedRef.matches ~it }\r
+ \r
+ // find rejection result for update type, if any\r
+ def result = protectedCmds[updateType.name()]\r
+ \r
+ // command requires authz if ref is protected and has a mapped rejection result\r
+ if (refPattern && result) {\r
+ \r
+ // verify user is a member of any authorized team\r
+ def team = authorizedTeams.find { user.isTeamMember it }\r
+ if (team) {\r
+ // don't adjust command result\r
+ logger.info "${user.username} authorized for ${updateType} of protected ref ${repository.name}:${updatedRef} (${command.oldId.name} -> ${command.newId.name})"\r
+ } else {\r
+ // mark command result as rejected\r
+ command.setResult(result, "${user.username} cannot ${updateType} protected ref ${repository.name}:${updatedRef} matching pattern ${refPattern}")\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2012 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.TeamModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import java.text.SimpleDateFormat\r
+\r
+import org.eclipse.jgit.api.Status;\r
+import org.eclipse.jgit.api.errors.JGitInternalException;\r
+import org.eclipse.jgit.diff.DiffEntry;\r
+import org.eclipse.jgit.diff.DiffFormatter;\r
+import org.eclipse.jgit.diff.RawTextComparator;\r
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
+import org.eclipse.jgit.lib.Constants;\r
+import org.eclipse.jgit.lib.IndexDiff;\r
+import org.eclipse.jgit.lib.ObjectId;\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.lib.Config\r
+import org.eclipse.jgit.patch.FileHeader;\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.revwalk.RevWalk;\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.eclipse.jgit.treewalk.FileTreeIterator;\r
+import org.eclipse.jgit.treewalk.EmptyTreeIterator;\r
+import org.eclipse.jgit.treewalk.CanonicalTreeParser;\r
+import org.eclipse.jgit.util.io.DisabledOutputStream;\r
+import org.slf4j.Logger\r
+import groovy.xml.MarkupBuilder\r
+\r
+import java.io.IOException;\r
+import java.security.MessageDigest\r
+\r
+\r
+/**\r
+ * Sample Gitblit Post-Receive Hook: sendmail-html\r
+ *\r
+ * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
+ * to the Git repository. This is the appropriate point to trigger an\r
+ * integration build or to send a notification.\r
+ * \r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push. If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ *\r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ * \r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ *\r
+ * If you want this hook script to fail and abort all subsequent scripts in the\r
+ * chain, "return false" at the appropriate failure points.\r
+ * \r
+ * Bound Variables:\r
+ * gitblit Gitblit Server com.gitblit.GitBlit\r
+ * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
+ * user Gitblit User com.gitblit.models.UserModel\r
+ * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ * url Base url for Gitblit java.lang.String\r
+ * logger Logs messages to Gitblit org.slf4j.Logger\r
+ * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ * def myCustomField = repository.customFields.myCustomField\r
+ * \r
+ */\r
+\r
+com.gitblit.models.UserModel userModel = user\r
+\r
+// Indicate we have started the script\r
+logger.info("sendmail-html hook triggered by ${user.username} for ${repository.name}")\r
+\r
+/*\r
+ * Primitive email notification.\r
+ * This requires the mail settings to be properly configured in Gitblit.\r
+ */\r
+\r
+Repository r = gitblit.getRepository(repository.name)\r
+\r
+// reuse existing repository config settings, if available\r
+Config config = r.getConfig()\r
+def mailinglist = config.getString('hooks', null, 'mailinglist')\r
+def emailprefix = config.getString('hooks', null, 'emailprefix')\r
+\r
+// set default values\r
+def toAddresses = []\r
+if (emailprefix == null) {\r
+ emailprefix = '[Gitblit]'\r
+}\r
+\r
+if (mailinglist != null) {\r
+ def addrs = mailinglist.split(/(,|\s)/)\r
+ toAddresses.addAll(addrs)\r
+}\r
+\r
+// add all mailing lists defined in gitblit.properties or web.xml\r
+toAddresses.addAll(GitBlit.getStrings(Keys.mail.mailingLists))\r
+\r
+// add all team mailing lists\r
+def teams = gitblit.getRepositoryTeams(repository)\r
+for (team in teams) {\r
+ TeamModel model = gitblit.getTeamModel(team)\r
+ if (model.mailingLists) {\r
+ toAddresses.addAll(model.mailingLists)\r
+ }\r
+}\r
+\r
+// add all mailing lists for the repository\r
+toAddresses.addAll(repository.mailingLists)\r
+\r
+// define the summary and commit urls\r
+def repo = repository.name\r
+def summaryUrl = url + "/summary?r=$repo"\r
+def baseCommitUrl = url + "/commit?r=$repo&h="\r
+def baseBlobDiffUrl = url + "/blobdiff/?r=$repo&h="\r
+def baseCommitDiffUrl = url + "/commitdiff/?r=$repo&h="\r
+def forwardSlashChar = gitblit.getString(Keys.web.forwardSlashCharacter, '/')\r
+\r
+if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
+ repo = repo.replace('/', forwardSlashChar).replace('/', '%2F')\r
+ summaryUrl = url + "/summary/$repo"\r
+ baseCommitUrl = url + "/commit/$repo/"\r
+ baseBlobDiffUrl = url + "/blobdiff/$repo/"\r
+ baseCommitDiffUrl = url + "/commitdiff/$repo/"\r
+}\r
+\r
+class HtmlMailWriter {\r
+ Repository repository\r
+ def url\r
+ def baseCommitUrl\r
+ def baseCommitDiffUrl\r
+ def baseBlobDiffUrl\r
+ def mountParameters\r
+ def forwardSlashChar\r
+ def includeGravatar\r
+ def shortCommitIdLength\r
+ def commitCount = 0\r
+ def commands\r
+ def writer = new StringWriter();\r
+ def builder = new MarkupBuilder(writer)\r
+\r
+ def writeStyle() {\r
+ builder.style(type:"text/css", '''\r
+ .table td {\r
+ vertical-align: middle;\r
+ }\r
+ tr.noborder td {\r
+ border: none;\r
+ padding-top: 0px;\r
+ }\r
+ .gravatar-column {\r
+ width: 5%; \r
+ }\r
+ .author-column {\r
+ width: 20%; \r
+ }\r
+ .commit-column {\r
+ width: 5%; \r
+ }\r
+ .status-column {\r
+ width: 10%;\r
+ }\r
+ .table-disable-hover.table tbody tr:hover td,\r
+ .table-disable-hover.table tbody tr:hover th {\r
+ background-color: inherit;\r
+ }\r
+ .table-disable-hover.table-striped tbody tr:nth-child(odd):hover td,\r
+ .table-disable-hover.table-striped tbody tr:nth-child(odd):hover th {\r
+ background-color: #f9f9f9;\r
+ }\r
+ ''')\r
+ }\r
+\r
+ def writeBranchTitle(type, name, action, number) {\r
+ builder.div('class' : 'pageTitle') {\r
+ builder.span('class':'project') {\r
+ mkp.yield "$type "\r
+ span('class': 'repository', name )\r
+ if (number > 0) {\r
+ mkp.yield " $action ($number commits)"\r
+ } else {\r
+ mkp.yield " $action"\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ def writeBranchDeletedTitle(type, name) {\r
+ builder.div('class' : 'pageTitle', 'style':'color:red') {\r
+ builder.span('class':'project') {\r
+ mkp.yield "$type "\r
+ span('class': 'repository', name )\r
+ mkp.yield " deleted"\r
+ }\r
+ }\r
+ }\r
+\r
+ def commitUrl(RevCommit commit) {\r
+ "${baseCommitUrl}$commit.id.name"\r
+ }\r
+\r
+ def commitDiffUrl(RevCommit commit) {\r
+ "${baseCommitDiffUrl}$commit.id.name"\r
+ }\r
+\r
+ def encoded(String path) {\r
+ path.replace('/', forwardSlashChar).replace('/', '%2F')\r
+ }\r
+\r
+ def blobDiffUrl(objectId, path) {\r
+ if (mountParameters) {\r
+ // REST style\r
+ "${baseBlobDiffUrl}${objectId.name()}/${encoded(path)}"\r
+ } else {\r
+ "${baseBlobDiffUrl}${objectId.name()}&f=${path}"\r
+ }\r
+\r
+ }\r
+\r
+ def writeCommitTable(commits, includeChangedPaths=true) {\r
+ // Write commits table\r
+ builder.table('class':"table table-disable-hover") {\r
+ thead {\r
+ tr {\r
+ th(colspan: includeGravatar ? 2 : 1, "Author")\r
+ th( "Commit" )\r
+ th( "Message" )\r
+ }\r
+ }\r
+ tbody() {\r
+\r
+ // Write all the commits\r
+ for (commit in commits) {\r
+ writeCommit(commit)\r
+\r
+ if (includeChangedPaths) {\r
+ // Write detail on that particular commit\r
+ tr('class' : 'noborder') {\r
+ td (colspan: includeGravatar ? 3 : 2)\r
+ td (colspan:2) { writeStatusTable(commit) }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ def writeCommit(commit) {\r
+ def abbreviated = repository.newObjectReader().abbreviate(commit.id, shortCommitIdLength).name()\r
+ def author = commit.authorIdent.name\r
+ def email = commit.authorIdent.emailAddress\r
+ def message = commit.shortMessage\r
+ builder.tr {\r
+ if (includeGravatar) {\r
+ td('class':"gravatar-column") {\r
+ img(src:gravatarUrl(email), 'class':"gravatar")\r
+ }\r
+ }\r
+ td('class':"author-column", author)\r
+ td('class':"commit-column") {\r
+ a(href:commitUrl(commit)) {\r
+ span('class':"label label-info", abbreviated )\r
+ }\r
+ }\r
+ td {\r
+ mkp.yield message\r
+ a('class':'link', href:commitDiffUrl(commit), " [commitdiff]" )\r
+ }\r
+ }\r
+ }\r
+\r
+ def writeStatusLabel(style, tooltip) {\r
+ builder.span('class' : style, 'title' : tooltip )\r
+ }\r
+\r
+ def writeAddStatusLine(ObjectId id, FileHeader header) { \r
+ builder.td('class':'changeType') {\r
+ writeStatusLabel("addition", "addition")\r
+ }\r
+ builder.td {\r
+ a(href:blobDiffUrl(id, header.newPath), header.newPath)\r
+ }\r
+ }\r
+\r
+ def writeCopyStatusLine(ObjectId id, FileHeader header) {\r
+ builder.td('class':'changeType') {\r
+ writeStatusLabel("rename", "rename")\r
+ }\r
+ builder.td() {\r
+ a(href:blobDiffUrl(id, header.newPath), header.oldPath + " copied to " + header.newPath)\r
+ }\r
+ }\r
+\r
+ def writeDeleteStatusLine(ObjectId id, FileHeader header) {\r
+ builder.td('class':'changeType') {\r
+ writeStatusLabel("deletion", "deletion")\r
+ }\r
+ builder.td() {\r
+ a(href:blobDiffUrl(id, header.oldPath), header.oldPath)\r
+ }\r
+ }\r
+\r
+ def writeModifyStatusLine(ObjectId id, FileHeader header) {\r
+ builder.td('class':'changeType') {\r
+ writeStatusLabel("modification", "modification")\r
+ }\r
+ builder.td() {\r
+ a(href:blobDiffUrl(id, header.oldPath), header.oldPath)\r
+ }\r
+ }\r
+\r
+ def writeRenameStatusLine(ObjectId id, FileHeader header) {\r
+ builder.td('class':'changeType') {\r
+ writeStatusLabel("rename", "rename")\r
+ }\r
+ builder.td() {\r
+ mkp.yield header.oldPath\r
+ mkp.yieldUnescaped "<b> -&rt; </b>"\r
+ a(href:blobDiffUrl(id, header.newPath), header.newPath)\r
+ }\r
+ }\r
+\r
+ def writeStatusLine(ObjectId id, FileHeader header) {\r
+ builder.tr {\r
+ switch (header.changeType) {\r
+ case ChangeType.ADD:\r
+ writeAddStatusLine(id, header)\r
+ break;\r
+ case ChangeType.COPY:\r
+ writeCopyStatusLine(id, header)\r
+ break;\r
+ case ChangeType.DELETE:\r
+ writeDeleteStatusLine(id, header)\r
+ break;\r
+ case ChangeType.MODIFY:\r
+ writeModifyStatusLine(id, header)\r
+ break;\r
+ case ChangeType.RENAME:\r
+ writeRenameStatusLine(id, header)\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ def writeStatusTable(RevCommit commit) {\r
+ DiffFormatter formatter = new DiffFormatter(DisabledOutputStream.INSTANCE)\r
+ formatter.setRepository(repository)\r
+ formatter.setDetectRenames(true)\r
+ formatter.setDiffComparator(RawTextComparator.DEFAULT);\r
+\r
+ def diffs\r
+ RevWalk rw = new RevWalk(repository)\r
+ if (commit.parentCount > 0) {\r
+ RevCommit parent = rw.parseCommit(commit.parents[0].id)\r
+ diffs = formatter.scan(parent.tree, commit.tree)\r
+ } else {\r
+ diffs = formatter.scan(new EmptyTreeIterator(),\r
+ new CanonicalTreeParser(null, rw.objectReader, commit.tree))\r
+ }\r
+ rw.dispose()\r
+ // Write status table\r
+ builder.table('class':"plain") {\r
+ tbody() {\r
+ for (DiffEntry entry in diffs) {\r
+ FileHeader header = formatter.toFileHeader(entry)\r
+ writeStatusLine(commit.id, header)\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ def md5(text) {\r
+\r
+ def digest = MessageDigest.getInstance("MD5")\r
+\r
+ //Quick MD5 of text\r
+ def hash = new BigInteger(1, digest.digest(text.getBytes()))\r
+ .toString(16)\r
+ .padLeft(32, "0")\r
+ hash.toString()\r
+ }\r
+\r
+ def gravatarUrl(email) {\r
+ def cleaned = email.trim().toLowerCase()\r
+ "http://www.gravatar.com/avatar/${md5(cleaned)}?s=30"\r
+ }\r
+\r
+ def writeNavbar() {\r
+ builder.div('class':"navbar navbar-fixed-top") {\r
+ div('class':"navbar-inner") {\r
+ div('class':"container") {\r
+ a('class':"brand", href:"${url}", title:"GitBlit") {\r
+ img(src:"${url}/gitblt_25_white.png",\r
+ width:"79",\r
+ height:"25",\r
+ 'class':"logo")\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ def write() {\r
+ builder.html {\r
+ head {\r
+ link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap.css")\r
+ link(rel:"stylesheet", href:"${url}/gitblit.css")\r
+ link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap-responsive.css")\r
+ writeStyle()\r
+ }\r
+ body {\r
+\r
+ writeNavbar()\r
+\r
+ div('class':"container") {\r
+\r
+ for (command in commands) {\r
+ def ref = command.refName\r
+ def refType = 'Branch'\r
+ if (ref.startsWith('refs/heads/')) {\r
+ ref = command.refName.substring('refs/heads/'.length())\r
+ } else if (ref.startsWith('refs/tags/')) {\r
+ ref = command.refName.substring('refs/tags/'.length())\r
+ refType = 'Tag'\r
+ }\r
+\r
+ switch (command.type) {\r
+ case ReceiveCommand.Type.CREATE:\r
+ def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
+ commitCount += commits.size()\r
+ if (refType == 'Branch') {\r
+ // new branch\r
+ writeBranchTitle(refType, ref, "created", commits.size())\r
+ writeCommitTable(commits, true)\r
+ } else {\r
+ // new tag\r
+ writeBranchTitle(refType, ref, "created", 0)\r
+ writeCommitTable(commits, false)\r
+ }\r
+ break\r
+ case ReceiveCommand.Type.UPDATE:\r
+ def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
+ commitCount += commits.size()\r
+ // fast-forward branch commits table\r
+ // Write header\r
+ writeBranchTitle(refType, ref, "updated", commits.size())\r
+ writeCommitTable(commits)\r
+ break\r
+ case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:\r
+ def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
+ commitCount += commits.size()\r
+ // non-fast-forward branch commits table\r
+ // Write header\r
+ writeBranchTitle(refType, ref, "updated [NON fast-forward]", commits.size())\r
+ writeCommitTable(commits)\r
+ break\r
+ case ReceiveCommand.Type.DELETE:\r
+ // deleted branch/tag\r
+ writeBranchDeletedTitle(refType, ref)\r
+ break\r
+ default:\r
+ break\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ writer.toString()\r
+ }\r
+\r
+}\r
+\r
+def mailWriter = new HtmlMailWriter()\r
+mailWriter.repository = r\r
+mailWriter.baseCommitUrl = baseCommitUrl\r
+mailWriter.baseBlobDiffUrl = baseBlobDiffUrl\r
+mailWriter.baseCommitDiffUrl = baseCommitDiffUrl\r
+mailWriter.forwardSlashChar = forwardSlashChar\r
+mailWriter.commands = commands\r
+mailWriter.url = url\r
+mailWriter.mountParameters = GitBlit.getBoolean(Keys.web.mountParameters, true)\r
+mailWriter.includeGravatar = GitBlit.getBoolean(Keys.web.allowGravatar, true)\r
+mailWriter.shortCommitIdLength = GitBlit.getInteger(Keys.web.shortCommitIdLength, 8)\r
+\r
+def content = mailWriter.write()\r
+\r
+// close the repository reference\r
+r.close()\r
+\r
+// tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
+def repositoryName = repository.name.substring(0, repository.name.length() - 4)\r
+gitblit.sendHtmlMail("${emailprefix} ${userModel.displayName} pushed ${mailWriter.commitCount} commits => $repositoryName",\r
+ content,\r
+ toAddresses)\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.TeamModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import java.text.SimpleDateFormat\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.lib.Config\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+\r
+/**\r
+ * Sample Gitblit Post-Receive Hook: sendmail\r
+ *\r
+ * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
+ * to the Git repository. This is the appropriate point to trigger an\r
+ * integration build or to send a notification.\r
+ * \r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push. If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ *\r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ * \r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ *\r
+ * If you want this hook script to fail and abort all subsequent scripts in the\r
+ * chain, "return false" at the appropriate failure points.\r
+ * \r
+ * Bound Variables:\r
+ * gitblit Gitblit Server com.gitblit.GitBlit\r
+ * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
+ * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
+ * user Gitblit User com.gitblit.models.UserModel\r
+ * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ * url Base url for Gitblit String\r
+ * logger Logs messages to Gitblit org.slf4j.Logger\r
+ * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ * def myCustomField = repository.customFields.myCustomField\r
+ * \r
+ */\r
+\r
+// Indicate we have started the script\r
+logger.info("sendmail hook triggered by ${user.username} for ${repository.name}")\r
+\r
+/*\r
+ * Primitive email notification.\r
+ * This requires the mail settings to be properly configured in Gitblit.\r
+ */\r
+\r
+Repository r = gitblit.getRepository(repository.name)\r
+\r
+// reuse existing repository config settings, if available\r
+Config config = r.getConfig()\r
+def mailinglist = config.getString('hooks', null, 'mailinglist')\r
+def emailprefix = config.getString('hooks', null, 'emailprefix')\r
+\r
+// set default values\r
+def toAddresses = []\r
+if (emailprefix == null)\r
+emailprefix = '[Gitblit]'\r
+\r
+if (mailinglist != null) {\r
+ def addrs = mailinglist.split(/(,|\s)/)\r
+ toAddresses.addAll(addrs)\r
+}\r
+\r
+// add all mailing lists defined in gitblit.properties or web.xml\r
+toAddresses.addAll(gitblit.getStrings(Keys.mail.mailingLists))\r
+\r
+// add all team mailing lists\r
+def teams = gitblit.getRepositoryTeams(repository)\r
+for (team in teams) {\r
+ TeamModel model = gitblit.getTeamModel(team)\r
+ if (model.mailingLists) {\r
+ toAddresses.addAll(model.mailingLists)\r
+ }\r
+}\r
+\r
+// add all mailing lists for the repository\r
+toAddresses.addAll(repository.mailingLists)\r
+\r
+// define the summary and commit urls\r
+def repo = repository.name\r
+def summaryUrl\r
+def commitUrl\r
+if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
+ repo = repo.replace('/', gitblit.getString(Keys.web.forwardSlashCharacter, '/')).replace('/', '%2F')\r
+ summaryUrl = url + "/summary/$repo"\r
+ commitUrl = url + "/commit/$repo/"\r
+} else {\r
+ summaryUrl = url + "/summary?r=$repo"\r
+ commitUrl = url + "/commit?r=$repo&h="\r
+}\r
+\r
+// construct a simple text summary of the changes contained in the push\r
+def branchBreak = '>---------------------------------------------------------------\n'\r
+def commitBreak = '\n\n ----\n'\r
+def commitCount = 0\r
+def changes = ''\r
+SimpleDateFormat df = new SimpleDateFormat(gitblit.getString(Keys.web.datetimestampLongFormat, 'EEEE, MMMM d, yyyy h:mm a z'))\r
+def table = { "\n ${JGitUtils.getDisplayName(it.authorIdent)}\n ${df.format(JGitUtils.getCommitDate(it))}\n\n $it.shortMessage\n\n $commitUrl$it.id.name" }\r
+for (command in commands) {\r
+ def ref = command.refName\r
+ def refType = 'branch'\r
+ if (ref.startsWith('refs/heads/')) {\r
+ ref = command.refName.substring('refs/heads/'.length())\r
+ } else if (ref.startsWith('refs/tags/')) {\r
+ ref = command.refName.substring('refs/tags/'.length())\r
+ refType = 'tag'\r
+ }\r
+ \r
+ switch (command.type) {\r
+ case ReceiveCommand.Type.CREATE:\r
+ def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
+ commitCount += commits.size()\r
+ // new branch\r
+ changes += "\n$branchBreak new $refType $ref created ($commits.size commits)\n$branchBreak"\r
+ changes += commits.collect(table).join(commitBreak)\r
+ changes += '\n'\r
+ break\r
+ case ReceiveCommand.Type.UPDATE:\r
+ def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
+ commitCount += commits.size()\r
+ // fast-forward branch commits table\r
+ changes += "\n$branchBreak $ref $refType updated ($commits.size commits)\n$branchBreak"\r
+ changes += commits.collect(table).join(commitBreak)\r
+ changes += '\n'\r
+ break\r
+ case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:\r
+ def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
+ commitCount += commits.size()\r
+ // non-fast-forward branch commits table\r
+ changes += "\n$branchBreak $ref $refType updated [NON fast-forward] ($commits.size commits)\n$branchBreak"\r
+ changes += commits.collect(table).join(commitBreak)\r
+ changes += '\n'\r
+ break\r
+ case ReceiveCommand.Type.DELETE:\r
+ // deleted branch/tag\r
+ changes += "\n$branchBreak $ref $refType deleted\n$branchBreak"\r
+ break\r
+ default:\r
+ break\r
+ }\r
+}\r
+// close the repository reference\r
+r.close()\r
+\r
+// tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
+gitblit.sendMail("$emailprefix $user.username pushed $commitCount commits => $repository.name", "$summaryUrl\n$changes", toAddresses)
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright 2011 Wolfgang Gassler gassler.org\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.TeamModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import java.text.SimpleDateFormat\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.lib.Config\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+import org.eclipse.jgit.lib.IndexDiff\r
+import org.eclipse.jgit.lib.Constants\r
+import com.gitblit.utils.DiffUtils\r
+\r
+/**\r
+ * Gitblit Post-Receive Hook: thebuggenie\r
+ * www.thebuggenie.com\r
+ * \r
+ * Submit the commit information to thebuggenie bug tracker by calling thebuggenie client tool\r
+ * \r
+ * Config of the Script:\r
+ * \r
+ * Setup a custom gitblit field in the proprties file of gitblit by adding the following line\r
+ * groovy.customFields = "thebuggenieProjectId=TheBugGennie project id (used for thebuggenie hoocks)"\r
+ * This field allows to specify the project id of thebuggenie project in the edit section of gitblit\r
+ * \r
+ * Furthermore you need to set the path to thebuggenie client tool by adding the following property to\r
+ * the gitblit properties file\r
+ * thebuggenie.tbg_cli = /var/www/thebuggenie_root/tbg_cli\r
+ */\r
+\r
+// Indicate we have started the script\r
+logger.info("thebuggenie hook triggered by ${user.username} for ${repository.name}")\r
+\r
+//fetch the repository data\r
+Repository r = gitblit.getRepository(repository.name)\r
+\r
+//get project id which is defined in the git repo metadata\r
+def tbgProjectId = repository.customFields.thebuggenieProjectId\r
+//get path to the thebuggenie client tool which is defined in the gitblit proprties files\r
+def tbgCliPath = gitblit.getString('thebuggenie.tbg_cli', '/var/www/thebuggenie/tbg_cli')\r
+def tbgCliDirPath = new File(tbgCliPath).getParent()\r
+\r
+for(command in commands) {\r
+ //fetch all pushed commits\r
+ def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
+ for (commit in commits) {\r
+ //get hashes and author data of commit\r
+ def oldhash = commit.getParent(0).getId().getName()\r
+ def newhash = commit.getId().getName()\r
+ def authorIdent = commit.getAuthorIdent()\r
+ def author = "${authorIdent.name} <${authorIdent.emailAddress}>"\r
+ //fetch all changed files of the commit\r
+ def files = JGitUtils.getFilesInCommit(r,commit)\r
+ def changedFiles = ""\r
+ for (f in files) {\r
+ //transform file data to the format which is needed by thebuggenie\r
+ changedFiles += f.changeType.toString().substring(0,1)+"\t${f.path}\n"\r
+ }\r
+ //ok let's submit all information to thebuggenie by calling the client tool\r
+// def shc = "$tbgCliPath vcs_integration:report_commit $tbgProjectId \"$author\" $newhash \"${commit.fullMessage}\" \"$changedFiles\" $oldhash ${commit.commitTime}"\r
+ def shc = [tbgCliPath, "vcs_integration:report_commit", tbgProjectId, author, newhash, commit.getFullMessage(), changedFiles, oldhash, commit.getCommitTime()];\r
+ logger.info("executing in path " + tbgCliDirPath + ": "+shc)\r
+ shc.execute(null, new File(tbgCliDirPath))\r
+ }\r
+}\r
+\r
+// close the repository reference\r
+r.close()\r
--StartPath="%CD%" ^\r
--StartClass=com.gitblit.Launcher ^\r
--StartMethod=main ^\r
- --StartParams="--storePassword;gitblit" ^\r
+ --StartParams="--storePassword;gitblit;--baseFolder;%CD%\data" ^\r
--StartMode=jvm ^\r
--StopPath="%CD%" ^\r
--StopClass=com.gitblit.Launcher ^\r
--StopMethod=main ^\r
- --StopParams="--stop" ^\r
+ --StopParams="--stop;--baseFolder;%CD%\data" ^\r
--StopMode=jvm ^\r
--Classpath="%CD%\gitblit.jar" ^\r
--Jvm=auto ^\r
--- /dev/null
+[project "main"]\r
+ title = Main Repositories\r
+ description = main group of repositories
\ No newline at end of file
-## Gitblit WAR Setup\r
+## Gitblit WAR Installation & Setup\r
\r
1. Download [Gitblit WAR %VERSION%](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%) to the webapps folder of your servlet container. \r
2. You may have to manually extract the WAR (zip file) to a folder within your webapps folder.\r
-3. Copy the `WEB-INF/users.conf` file to a location outside the webapps folder that is accessible by your servlet container. \r
-Optionally copy the example hook scripts in `WEB-INF/groovy` to a location outside the webapps folder that is accesible by your servlet container.\r
-4. The Gitblit webapp is configured through its `web.xml` file. \r
-Open `web.xml` in your favorite text editor and make sure to review and set:\r
- - <context-parameter> *git.repositoryFolder* (set the full path to your repositories folder)\r
- - <context-parameter> *groovy.scriptsFolder* (set the full path to your Groovy hook scripts folder)\r
- - <context-parameter> *groovy.grapeFolder* (set the full path to your Groovy Grape artifact cache)\r
- - <context-parameter> *web.projectsFile* (set the full path to your projects metadata file)\r
- - <context-parameter> *realm.userService* (set the full path to `users.conf`)\r
+3. By default, the Gitblit webapp is configured through `WEB-INF/data/gitblit.properties`.<br/>\r
+Open `WEB-INF/data/gitblit.properties` in your favorite text editor and make sure to review and set:\r
- <context-parameter> *git.packedGitLimit* (set larger than the size of your largest repository)\r
- <context-parameter> *git.streamFileThreshold* (set larger than the size of your largest committed file)\r
-5. You may have to restart your servlet container. \r
-6. Open your browser to <http://localhost/gitblit> or whatever the url should be.\r
-7. Enter the default administrator credentials: **admin / admin** and click the *Login* button \r
+4. You may have to restart your servlet container. \r
+5. Open your browser to <http://localhost/gitblit> or whatever the url should be.\r
+6. Enter the default administrator credentials: **admin / admin** and click the *Login* button \r
**NOTE:** Make sure to change the administrator username and/or password!! \r
\r
-## Gitblit GO Setup\r
+### WAR Data Location\r
+By default, Gitblit WAR stores all data (users, settings, repositories, etc) in `${contextFolder}/WEB-INF/data`. This is fine for a quick setup, but there are many reasons why you don't want to keep your data within the webapps folder of your servlet container. You may specify an external location for your data by editing `WEB-INF/web.xml` and manipulating the *baseFolder* context parameter. Choose a location that is writeable by your servlet container. Your servlet container may be smart enough to recognize the change and to restart Gitblit.\r
+\r
+On the next restart of Gitblit, Gitblit will copy the contents of the `WEB-INF/data` folder to your specified *baseFolder* **IF** the file `${baseFolder}/gitblit.properties` does not already exist. This allows you to get going with minimal fuss.\r
+\r
+Specifying an alternate *baseFolder* also allows for simpler upgrades in the future.\r
+\r
+## Gitblit GO Installation & Setup\r
\r
1. Download and unzip [Gitblit GO %VERSION%](http://code.google.com/p/gitblit/downloads/detail?name=%GO%). \r
*Its best to eliminate spaces in the path name.* \r
-2. The server itself is configured through a simple text file. \r
-Open `gitblit.properties` in your favorite text editor and make sure to review and set:\r
- - *git.repositoryFolder* (path may be relative or absolute)\r
- - *groovy.scriptsFolder* (path may be relative or absolute)\r
- - *groovy.grapeFolder* (path may be relative or absolute)\r
- - *server.tempFolder* (path may be relative or absolute)\r
+2. The server itself is configured through a simple text file.<br/>\r
+Open `data/gitblit.properties` in your favorite text editor and make sure to review and set:\r
- *server.httpPort* and *server.httpsPort*\r
- *server.httpBindInterface* and *server.httpsBindInterface* \r
- *server.storePassword*\r
**https** is strongly recommended because passwords are insecurely transmitted form your browser/git client using Basic authentication!\r
- *git.packedGitLimit* (set larger than the size of your largest repository)\r
- *git.streamFileThreshold* (set larger than the size of your largest committed file)\r
-3. Execute `authority.cmd` or `java -jar authority.jar` from a command-line\r
+3. Execute `authority.cmd` or `java -jar authority.jar --baseFolder data` from a command-line\r
1. fill out the fields in the *new certificate defaults* dialog\r
2. enter the store password used in *server.storePassword* when prompted. This generates an SSL certificate for **localhost**.\r
3. you may want to generate an SSL certificate for the hostname or ip address hostnames you are serving from<br/>**NOTE:** You can only have **one** SSL certificate specified for a port.\r
5. exit the authority app\r
-4. Execute `gitblit.cmd` or `java -jar gitblit.jar` from a command-line\r
+4. Execute `gitblit.cmd` or `java -jar gitblit.jar --baseFolder data` from a command-line\r
5. Open your browser to <http://localhost:8080> or <https://localhost:8443> depending on your chosen configuration.\r
6. Enter the default administrator credentials: **admin / admin** and click the *Login* button \r
**NOTE:** Make sure to change the administrator username and/or password!! \r
\r
+### GO Data Location\r
+\r
+By default, Gitblit GO stores all data (users, settings, repositories, etc) in the `data` subfolder of your GO installation. You may specify an external location for your data on the command-line by setting the *--baseFolder* argument. If you relocate the data folder then you must supply the *--baseFolder* argument to both GO and the Certificate Authority.\r
+\r
+If you are deploying Gitblit to a *nix platform, you might consider moving the data folder out of the GO installation folder and then creating a symlink named "data" that points to your moved folder.\r
+\r
### Creating your own Self-Signed SSL Certificate\r
Gitblit GO (and Gitblit Certificate Authority) automatically generates a Certificate Authority (CA) certificate and an ssl certificate signed by this CA certificate that is bound to *localhost*.\r
\r
-Remote Eclipse/EGit/JGit clients (<= 2.1.0) will fail to communicate using this certificate because JGit always verifies the hostname of the certificate, regardless of the *http.sslVerify=false* client-side setting.\r
+Remote Eclipse/EGit/JGit clients (<= 2.2.0) will fail to communicate using this certificate because JGit always verifies the hostname of the certificate, regardless of the *http.sslVerify=false* client-side setting.\r
\r
The EGit failure message is something like:\r
\r
\r
If you want to serve your repositories to another machine over https then you will want to generate a new certificate for the hostname or ip address you are serving from.\r
\r
-1. `authority.cmd` or `java -jar authority.jar`\r
+1. `authority.cmd` or `java -jar authority.jar --baseFolder data`\r
2. Click the *new ssl certificate* button (red rosette in the toolbar in upper left of window)\r
3. Enter the hostname or ip address\r
4. Make sure the checkbox *serve https with this certificate* is checked\r
\r
If you decide to change the value of *server.storePassword* (recommended) <u>after</u> you have already started Gitblit or Gitblit Certificate Authority, then you will have to delete the following files and then restart the Gitblit Certificate Authority app:\r
\r
-1. serverKeyStore.jks\r
-2. serverTrustStore.jks\r
-3. certs/caKeyStore.jks\r
-4. certs/ca.crt\r
-5. certs/caRevocationList.crl (optional)\r
+1. data/serverKeyStore.jks\r
+2. data/serverTrustStore.jks\r
+3. data/certs/caKeyStore.jks\r
+4. data/certs/ca.crt\r
+5. data/certs/caRevocationList.crl (optional)\r
\r
### Client SSL Certificates\r
SINCE 1.2.0\r
How do you make your servlet container trust a client certificate?\r
\r
In the WAR variant, you will have to manually setup your servlet container to:\r
+\r
1. want/need client certificates\r
2. trust a CA certificate used to sign your client certificates\r
3. generate client certificates signed by your CA certificate\r
\r
#### Creating SSL Certificates with Gitblit Certificate Authority\r
\r
-When you generate a new client certificate, a zip file bundle is created which includes a P12 keystore for browsers and a PEM keystore for Git. Both of these are password-protected. Additionally, a personalized README file is generated with setup instructions for popular browsers and Git. The README is generated from `certs\instructions.tmpl` and can be modified to suit your needs.\r
+When you generate a new client certificate, a zip file bundle is created which includes a P12 keystore for browsers and a PEM keystore for Git. Both of these are password-protected. Additionally, a personalized README file is generated with setup instructions for popular browsers and Git. The README is generated from `data\certs\instructions.tmpl` and can be modified to suit your needs.\r
\r
-1. `authority.cmd` or `java -jar authority.jar`\r
+1. `authority.cmd` or `java -jar authority.jar --baseFolder data`\r
2. Select the user for which to generate the certificate\r
3. Click the *new certificate* button and enter the expiration date of the certificate. You must also enter a password for the generated keystore. This password is *not* the same as the user's login password. This password is used to protect the privatekey and public certificate you will generate for the selected user. You must also enter a password hint for the user.\r
4. If your mail server settings are properly configured you will have a *send email* checkbox which you can use to immediately send the generated certificate bundle to the user.\r
#### Command-Line Parameters\r
Command-Line parameters override the values in `gitblit.properties` at runtime.\r
\r
+ --baseFolder The default base folder for all relative file reference settings\r
--repositoriesFolder Git Repositories Folder\r
--userService Authentication and Authorization Service (filename or fully qualified classname)\r
--useNio Use NIO Connector else use Socket Connector.\r
\r
**Example**\r
\r
- java -jar gitblit.jar --userService c:\myrealm.config --storePassword something\r
+ java -jar gitblit.jar --userService c:/myrealm.config --storePassword something --baseFolder c:/data\r
\r
#### Overriding Gitblit GO's Log4j Configuration\r
\r
Alternatively, you can respecify *web.forwardSlashCharacter*.\r
\r
## Upgrading Gitblit\r
-Generally, upgrading is easy.\r
-\r
-Since Gitblit does not use a database the only files you have to worry about are your configuration file (`gitblit.properties` or `web.xml`) and possibly your `users.conf` or `users.properties` file.\r
\r
Any important changes to the setting keys or default values will always be mentioned in the [release log](releases.html).\r
\r
\r
`users.properties` and its user service implementation are deprecated as of v0.8.0.\r
\r
-### Upgrading Gitblit WAR\r
-1. Backup your `web.xml` file \r
-Backup your `web.properties` file (if you have one, these are the setting overrides from using the RPC administration service)\r
-2. Delete currently deployed gitblit WAR\r
-3. Deploy new WAR and overwrite the `web.xml` file with your backup\r
-4. Review and optionally apply any new settings as indicated in the [release log](releases.html). \r
+### Upgrading Gitblit WAR (1.2.1+)\r
+1. Make sure your `WEB-INF/web.xml` *baseFolder* context parameter is not `${contextFolder}/WEB-INF/data`!<br/>\r
+If it is, move your `WEB-INF/data` folder to a location writeable by your servlet container.\r
+2. Deploy new WAR\r
+3. Edit the new WAR's `WEB-INF/web.xml` file and set the *baseFolder* context parameter to your external baseFolder.\r
+4. Review and optionally apply any new settings as indicated in the [release log](releases.html) to `${baseFolder}/gitblit.properties`. \r
\r
-### Upgrading Gitblit GO\r
+### Upgrading Gitblit GO (1.2.1+)\r
\r
-1. Backup your `gitblit.properties` file\r
-2. Backup your `users.properties` file *(if it is located in the Gitblit GO folder)* \r
-OR \r
-Backup your `users.conf` file *(if it is located in the Gitblit GO folder)*\r
-3. Backup your Groovy hook scripts\r
-4. Unzip Gitblit GO to a new folder\r
-5. Overwrite the `gitblit.properties` file with your backup\r
-6. Overwrite the `users.properties` file with your backup *(if it was located in the Gitblit GO folder)* \r
-OR \r
-Overwrite the `users.conf` file with your backup *(if it was located in the Gitblit GO folder)*\r
-7. Review and optionally apply any new settings as indicated in the [release log](releases.html).\r
+1. Unzip Gitblit GO to a new folder\r
+2. Copy your `data` folder from your current Gitblit installation to the new folder and overwrite any conflicts\r
+3. Review and optionally apply any new settings as indicated in the [release log](releases.html) to `data/gitblit.properties`.\r
+\r
+In *nix systems, there are other tricks you can play like symlinking the `data` folder or symlinking the GO folder.\r
+All platforms support the *--baseFolder* command-line argument.\r
+\r
+### Upgrading Gitblit WAR (pre-1.2.1)\r
+\r
+1. Create a `data` as outlined in step 1 of *Upgrading Gitblit GO (pre-1.2.1)*\r
+2. Copy your existing web.xml to your data folder\r
+3. Deploy new WAR\r
+4. Copy the new WAR's `WEB-INF/data/gitblit.properties` file to your data folder\r
+5. Manually apply any changes you made to your original web.xml file to the gitblit.properties file you copied to your data folder\r
+6. Edit the new WAR's `WEB-INF/web.xml` file and set the *baseFolder* context parameter to your external baseFolder.\r
+\r
+### Upgrading Gitblit GO (pre-1.2.1)\r
+1. Create a `data` folder and copy the following files and folders to it:\r
+ - users.conf\r
+ - projects.conf *(if you have one)*\r
+ - gitblit.properties\r
+ - serverKeystore.jks\r
+ - serverTrustStore.jks\r
+ - certs folder\r
+ - groovy folder\r
+ - proposals folder\r
+ - and any other custom files (robots.txt, welcome/login markdown files, etc)\r
+2. Unzip Gitblit GO to a new folder\r
+3. Copy your `data` folder and overwrite the folder of the same name in the just-unzipped version\r
+4. Review and optionally apply any new settings as indicated in the [release log](releases.html) to `data/gitblit.properties`.\r
+\r
+**NOTE:** You may need to adjust your service definitions to include the `--baseFolder data` argument.\r
\r
#### Upgrading Windows Service\r
You may need to delete your old service definition and install a new one depending on what has changed in the release.\r
federationSets = \r
\r
#### Repository Names\r
-Repository names must be unique and are CASE-SENSITIVE ON CASE-SENSITIVE FILESYSTEMS. The name must be composed of letters, digits, or `/ _ - . ~`<br/>\r
+Repository names must be case-insensitive-unique but are CASE-SENSITIVE ON CASE-SENSITIVE FILESYSTEMS. The name must be composed of letters, digits, or `/ _ - . ~`<br/>\r
Whitespace is illegal.\r
\r
Repositories can be grouped within subfolders. e.g. *libraries/mycoollib.git* and *libraries/myotherlib.git*\r
\r
You can not use fast-forward merges on your client when using committer verification. You must specify *--no-ff* to ensure that a merge commit is created with your identity as the committer. Only the first parent chain is traversed when verifying commits.\r
\r
+#### Push Log\r
+\r
+Gitblit v1.2.1 introduces an incomplete push mechanism. All pushes are logged since 1.2.1, but the log has not yet been exposed through the web ui. This will be a feature of an upcoming release.\r
+\r
### Teams\r
\r
Since v0.8.0, Gitblit supports *teams* for the original `users.properties` user service and the current default user service `users.conf`. Teams have assigned users and assigned repositories. A user can be a member of multiple teams and a repository may belong to multiple teams. This allows the administrator to quickly add a user to a team without having to keep track of all the appropriate repositories. \r
\r
### Current Release\r
\r
+<div class="alert alert-info">\r
+<h4>Update Note 1.2.1</h4>\r
+Because there are now several types of files and folders that must be considered Gitblit data, the default location for data has changed.\r
+<p>You will need to move a few files around when upgrading. Please see the Upgrading section of the <a href="setup.html">setup</a> page for details.</p>\r
+\r
+<b>Express Users</b> make sure to update your web.xml file with the ${baseFolder} values!\r
+</div>\r
+\r
**%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%) | [war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%) | [express](http://code.google.com/p/gitblit/downloads/detail?name=%EXPRESS%) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=%FEDCLIENT%) | [manager](http://code.google.com/p/gitblit/downloads/detail?name=%MANAGER%) | [api](http://code.google.com/p/gitblit/downloads/detail?name=%API%)) based on [%JGIT%][jgit] *released %BUILDDATE%*\r
\r
#### fixes\r
- Added nullchecking when concurrently forking a repository and trying to display it's fork network (issue-187)\r
- Fixed bug where permission changes were not visible in the web ui to a logged-in user until the user logged-out and then logged back in again (issue-186)\r
- Fixed nullpointer on creating a repository with mixed case (issue 185)\r
-- Fixed nullpointer when using web.allowForking = true && git.cacheRepositoryList = false (issue 182)\r
+- Fixed nullpointer when using *web.allowForking = true* && *git.cacheRepositoryList = false* (issue 182)\r
- Likely fix for commit and commitdiff page failures when a submodule reference changes (issue 178)\r
- Build project models from the repository model cache, when possible, to reduce page load time (issue 172)\r
- Fixed loading of Brazilian Portuguese translation from *nix server (github/inaiat)\r
\r
#### changes\r
\r
+- Gitblit GO and Gitblit WAR are now both configured by `gitblit.properties`. WAR is no longer configured by `web.xml`.<br/>\r
+However, Express for OpenShift continues to be configured by `web.xml`.\r
+- Support for a *--baseFolder* command-line argument for Gitblit GO and Gitblit Certificate Authority\r
+- Support for specifying a *${baseFolder}* parameter in `gitblit.properties` and `web.xml` for several settings\r
- Improve history display of a submodule link\r
- Updated Korean translation (github/ds5apn)\r
- Updated checkstyle definition (github/mystygage)\r
### Older Releases\r
\r
<div class="alert alert-info">\r
-<h4>Update Note</h4>\r
+<h4>Update Note 1.2.0</h4>\r
The permissions model has changed in the 1.2.0 release.\r
<p>If you are updating your server, you must also update any Gitblit Manager and Federation Client installs to 1.2.0 as well. The data model used by the RPC mechanism has changed slightly for the new permissions infrastructure.</p>\r
</div>\r
<hr/>\r
\r
<div class="alert alert-error">\r
-<h4>Update Note</h4>\r
+<h4>Update Note 1.1.0</h4>\r
If you are updating from an earlier release AND you have indexed branches with the Lucene indexing feature, you need to be aware that this release will completely re-index your repositories. Please be sure to provide ample heap resources as appropriate for your installation.\r
</div>\r
\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import java.text.MessageFormat;\r
-\r
-import com.gitblit.GitBlit\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.UserModel\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-import com.gitblit.utils.ClientLogger\r
-\r
-/**\r
- * Sample Gitblit Pre-Receive Hook: blockpush\r
- * \r
- * This script could and perhaps should be further developed to provide\r
- * a full repository-branch permissions system similar to gitolite or gitosis.\r
- *\r
- * The Pre-Receive hook is executed after an incoming push has been parsed,\r
- * validated, and objects have been written but BEFORE the refs are updated.\r
- * This is the appropriate point to block a push for some reason.\r
- *\r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.preReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push. If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- * \r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- *\r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- * \r
- * If you want this hook script to fail and abort all subsequent scripts in the\r
- * chain, "return false" at the appropriate failure points.\r
- *\r
- * Bound Variables:\r
- * gitblit Gitblit Server com.gitblit.GitBlit\r
- * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
- * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
- * user Gitblit User com.gitblit.models.UserModel\r
- * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- * url Base url for Gitblit String\r
- * logger Logs messages to Gitblit org.slf4j.Logger\r
- * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- * def myCustomField = repository.customFields.myCustomField\r
- * \r
- */\r
-\r
-// Indicate we have started the script\r
-logger.info("blockpush hook triggered by ${user.username} for ${repository.name}: checking ${commands.size} commands")\r
-\r
-/*\r
- * Example rejection of pushes to the master branch of example.git\r
- */\r
-def blocked = false\r
-switch (repository.name) {\r
- case 'ex@mple.git':\r
- for (ReceiveCommand command : commands) {\r
- def updatedRef = command.refName\r
- if (updatedRef.equals('refs/heads/master')) {\r
- // to reject a command set it's result to anything other than Result.NOT_ATTEMPTED\r
- command.setResult(Result.REJECTED_OTHER_REASON, "You are not permitted to write to ${repository.name}:${updatedRef}")\r
- blocked = true\r
- }\r
- }\r
- break\r
-\r
- default:\r
- break\r
-}\r
-\r
-if (blocked) {\r
- // return false to break the push hook chain\r
- return false\r
-}
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-\r
-/**\r
- * Sample Gitblit Post-Receive Hook: jenkins\r
- *\r
- * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
- * to the Git repository. This is the appropriate point to trigger an\r
- * integration build or to send a notification.\r
- * \r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push. If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- *\r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- * \r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- * \r
- * Bound Variables:\r
- * gitblit Gitblit Server com.gitblit.GitBlit\r
- * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
- * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
- * user Gitblit User com.gitblit.models.UserModel\r
- * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- * url Base url for Gitblit String\r
- * logger Logs messages to Gitblit org.slf4j.Logger\r
- * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- * def myCustomField = repository.customFields.myCustomField\r
- * \r
- */\r
-// Indicate we have started the script\r
-logger.info("jenkins hook triggered by ${user.username} for ${repository.name}")\r
-\r
-// This script requires Jenkins Git plugin 1.1.14 or later\r
-// http://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/\r
-\r
-// define your jenkins url here or set groovy.jenkinsServer in \r
-// gitblit.properties or web.xml\r
-def jenkinsUrl = gitblit.getString('groovy.jenkinsServer', 'http://yourserver/jenkins')\r
-\r
-// define the trigger url\r
-def triggerUrl = jenkinsUrl + "/git/notifyCommit?url=$url/git/$repository.name"\r
-\r
-// trigger the build\r
-new URL(triggerUrl).getContent()\r
+++ /dev/null
-/*\r
- * Copyright 2012 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.TeamModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import com.gitblit.utils.StringUtils\r
-import java.text.SimpleDateFormat\r
-import org.eclipse.jgit.api.CloneCommand\r
-import org.eclipse.jgit.api.Git\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.lib.Config\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.eclipse.jgit.util.FileUtils\r
-import org.slf4j.Logger\r
-\r
-/**\r
- * Sample Gitblit Post-Receive Hook: localclone\r
- *\r
- * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
- * to the Git repository. This is the appropriate point to trigger an\r
- * integration build or to send a notification.\r
- * \r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push. If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- *\r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- * \r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- *\r
- * If you want this hook script to fail and abort all subsequent scripts in the\r
- * chain, "return false" at the appropriate failure points.\r
- * \r
- * Bound Variables:\r
- * gitblit Gitblit Server com.gitblit.GitBlit\r
- * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
- * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
- * user Gitblit User com.gitblit.models.UserModel\r
- * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- * url Base url for Gitblit String\r
- * logger Logs messages to Gitblit org.slf4j.Logger\r
- * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- * def myCustomField = repository.customFields.myCustomField\r
- * \r
- */\r
-\r
-// Indicate we have started the script\r
-logger.info("localclone hook triggered by ${user.username} for ${repository.name}")\r
-\r
-def rootFolder = 'c:/test'\r
-def bare = false\r
-def cloneAllBranches = true\r
-def cloneBranch = 'refs/heads/master'\r
-def includeSubmodules = true\r
-\r
-def repoName = repository.name\r
-def destinationFolder = new File(rootFolder, StringUtils.stripDotGit(repoName))\r
-def srcUrl = 'file://' + new File(GitBlit.getRepositoriesFolder(), repoName).absolutePath\r
-\r
-// delete any previous clone\r
-if (destinationFolder.exists()) {\r
- FileUtils.delete(destinationFolder, FileUtils.RECURSIVE)\r
-}\r
-\r
-// clone the repository\r
-logger.info("cloning ${srcUrl} to ${destinationFolder}")\r
-CloneCommand cmd = Git.cloneRepository();\r
-cmd.setBare(bare)\r
-if (cloneAllBranches)\r
- cmd.setCloneAllBranches(true)\r
-else\r
- cmd.setBranch(cloneBranch)\r
-cmd.setCloneSubmodules(includeSubmodules)\r
-cmd.setURI(srcUrl)\r
-cmd.setDirectory(destinationFolder)\r
-Git git = cmd.call();\r
-git.repository.close()\r
-\r
-// report clone operation success back to pushing Git client\r
-clientLogger.info("${repoName} cloned to ${destinationFolder}")
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright 2012 Philip L. McMahon.\r
- *\r
- * Derived from blockpush.groovy, copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.UserModel\r
-\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-\r
-/**\r
- * Sample Gitblit Pre-Receive Hook: protect-refs\r
- * \r
- * This script provides basic authorization of receive command types for a list\r
- * of known ref patterns. Command types and unmatched ref patterns will be\r
- * ignored, meaning this script has an "allow by default" policy.\r
- *\r
- * This script works best when a repository requires authentication on push, but\r
- * can be used to enforce fast-forward commits or prohibit ref deletion by\r
- * setting the *authorizedTeams* variable to an empty list and adding a ".+"\r
- * entry to the *protectedRefs* list.\r
- *\r
- * The Pre-Receive hook is executed after an incoming push has been parsed,\r
- * validated, and objects have been written but BEFORE the refs are updated.\r
- * This is the appropriate point to block a push for some reason.\r
- *\r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.preReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push. If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- * \r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- *\r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- * \r
- * This script may reject one or more commands, but will never return false.\r
- * Subsequent scripts, if any, will always be invoked.\r
- *\r
- * Bound Variables:\r
- * gitblit Gitblit Server com.gitblit.GitBlit\r
- * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
- * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
- * user Gitblit User com.gitblit.models.UserModel\r
- * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- * url Base url for Gitblit String\r
- * logger Logs messages to Gitblit org.slf4j.Logger\r
- * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- * def myCustomField = repository.customFields.myCustomField\r
- * \r
- */\r
-\r
-// map of protected command types to returned results type\r
-// commands not included will skip authz check\r
-def protectedCmds = [\r
- UPDATE_NONFASTFORWARD: Result.REJECTED_NONFASTFORWARD,\r
- DELETE: Result.REJECTED_NODELETE\r
-]\r
-\r
-// list of regex patterns for protected refs\r
-def protectedRefs = [\r
- "refs/heads/master",\r
- "refs/tags/.+"\r
-]\r
-\r
-// teams which are authorized to perform protected commands on protected refs\r
-def authorizedTeams = [ "admins" ]\r
-\r
-for (ReceiveCommand command : commands) {\r
- def updateType = command.type\r
- def updatedRef = command.refName\r
- \r
- // find first regex which matches updated ref, if any\r
- def refPattern = protectedRefs.find { updatedRef.matches ~it }\r
- \r
- // find rejection result for update type, if any\r
- def result = protectedCmds[updateType.name()]\r
- \r
- // command requires authz if ref is protected and has a mapped rejection result\r
- if (refPattern && result) {\r
- \r
- // verify user is a member of any authorized team\r
- def team = authorizedTeams.find { user.isTeamMember it }\r
- if (team) {\r
- // don't adjust command result\r
- logger.info "${user.username} authorized for ${updateType} of protected ref ${repository.name}:${updatedRef} (${command.oldId.name} -> ${command.newId.name})"\r
- } else {\r
- // mark command result as rejected\r
- command.setResult(result, "${user.username} cannot ${updateType} protected ref ${repository.name}:${updatedRef} matching pattern ${refPattern}")\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Copyright 2012 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.TeamModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import java.text.SimpleDateFormat\r
-\r
-import org.eclipse.jgit.api.Status;\r
-import org.eclipse.jgit.api.errors.JGitInternalException;\r
-import org.eclipse.jgit.diff.DiffEntry;\r
-import org.eclipse.jgit.diff.DiffFormatter;\r
-import org.eclipse.jgit.diff.RawTextComparator;\r
-import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
-import org.eclipse.jgit.lib.Constants;\r
-import org.eclipse.jgit.lib.IndexDiff;\r
-import org.eclipse.jgit.lib.ObjectId;\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.lib.Config\r
-import org.eclipse.jgit.patch.FileHeader;\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.revwalk.RevWalk;\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.eclipse.jgit.treewalk.FileTreeIterator;\r
-import org.eclipse.jgit.treewalk.EmptyTreeIterator;\r
-import org.eclipse.jgit.treewalk.CanonicalTreeParser;\r
-import org.eclipse.jgit.util.io.DisabledOutputStream;\r
-import org.slf4j.Logger\r
-import groovy.xml.MarkupBuilder\r
-\r
-import java.io.IOException;\r
-import java.security.MessageDigest\r
-\r
-\r
-/**\r
- * Sample Gitblit Post-Receive Hook: sendmail-html\r
- *\r
- * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
- * to the Git repository. This is the appropriate point to trigger an\r
- * integration build or to send a notification.\r
- * \r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push. If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- *\r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- * \r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- *\r
- * If you want this hook script to fail and abort all subsequent scripts in the\r
- * chain, "return false" at the appropriate failure points.\r
- * \r
- * Bound Variables:\r
- * gitblit Gitblit Server com.gitblit.GitBlit\r
- * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
- * user Gitblit User com.gitblit.models.UserModel\r
- * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- * url Base url for Gitblit java.lang.String\r
- * logger Logs messages to Gitblit org.slf4j.Logger\r
- * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- * def myCustomField = repository.customFields.myCustomField\r
- * \r
- */\r
-\r
-com.gitblit.models.UserModel userModel = user\r
-\r
-// Indicate we have started the script\r
-logger.info("sendmail-html hook triggered by ${user.username} for ${repository.name}")\r
-\r
-/*\r
- * Primitive email notification.\r
- * This requires the mail settings to be properly configured in Gitblit.\r
- */\r
-\r
-Repository r = gitblit.getRepository(repository.name)\r
-\r
-// reuse existing repository config settings, if available\r
-Config config = r.getConfig()\r
-def mailinglist = config.getString('hooks', null, 'mailinglist')\r
-def emailprefix = config.getString('hooks', null, 'emailprefix')\r
-\r
-// set default values\r
-def toAddresses = []\r
-if (emailprefix == null) {\r
- emailprefix = '[Gitblit]'\r
-}\r
-\r
-if (mailinglist != null) {\r
- def addrs = mailinglist.split(/(,|\s)/)\r
- toAddresses.addAll(addrs)\r
-}\r
-\r
-// add all mailing lists defined in gitblit.properties or web.xml\r
-toAddresses.addAll(GitBlit.getStrings(Keys.mail.mailingLists))\r
-\r
-// add all team mailing lists\r
-def teams = gitblit.getRepositoryTeams(repository)\r
-for (team in teams) {\r
- TeamModel model = gitblit.getTeamModel(team)\r
- if (model.mailingLists) {\r
- toAddresses.addAll(model.mailingLists)\r
- }\r
-}\r
-\r
-// add all mailing lists for the repository\r
-toAddresses.addAll(repository.mailingLists)\r
-\r
-// define the summary and commit urls\r
-def repo = repository.name\r
-def summaryUrl = url + "/summary?r=$repo"\r
-def baseCommitUrl = url + "/commit?r=$repo&h="\r
-def baseBlobDiffUrl = url + "/blobdiff/?r=$repo&h="\r
-def baseCommitDiffUrl = url + "/commitdiff/?r=$repo&h="\r
-def forwardSlashChar = gitblit.getString(Keys.web.forwardSlashCharacter, '/')\r
-\r
-if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
- repo = repo.replace('/', forwardSlashChar).replace('/', '%2F')\r
- summaryUrl = url + "/summary/$repo"\r
- baseCommitUrl = url + "/commit/$repo/"\r
- baseBlobDiffUrl = url + "/blobdiff/$repo/"\r
- baseCommitDiffUrl = url + "/commitdiff/$repo/"\r
-}\r
-\r
-class HtmlMailWriter {\r
- Repository repository\r
- def url\r
- def baseCommitUrl\r
- def baseCommitDiffUrl\r
- def baseBlobDiffUrl\r
- def mountParameters\r
- def forwardSlashChar\r
- def includeGravatar\r
- def shortCommitIdLength\r
- def commitCount = 0\r
- def commands\r
- def writer = new StringWriter();\r
- def builder = new MarkupBuilder(writer)\r
-\r
- def writeStyle() {\r
- builder.style(type:"text/css", '''\r
- .table td {\r
- vertical-align: middle;\r
- }\r
- tr.noborder td {\r
- border: none;\r
- padding-top: 0px;\r
- }\r
- .gravatar-column {\r
- width: 5%; \r
- }\r
- .author-column {\r
- width: 20%; \r
- }\r
- .commit-column {\r
- width: 5%; \r
- }\r
- .status-column {\r
- width: 10%;\r
- }\r
- .table-disable-hover.table tbody tr:hover td,\r
- .table-disable-hover.table tbody tr:hover th {\r
- background-color: inherit;\r
- }\r
- .table-disable-hover.table-striped tbody tr:nth-child(odd):hover td,\r
- .table-disable-hover.table-striped tbody tr:nth-child(odd):hover th {\r
- background-color: #f9f9f9;\r
- }\r
- ''')\r
- }\r
-\r
- def writeBranchTitle(type, name, action, number) {\r
- builder.div('class' : 'pageTitle') {\r
- builder.span('class':'project') {\r
- mkp.yield "$type "\r
- span('class': 'repository', name )\r
- if (number > 0) {\r
- mkp.yield " $action ($number commits)"\r
- } else {\r
- mkp.yield " $action"\r
- }\r
- }\r
- }\r
- }\r
-\r
- def writeBranchDeletedTitle(type, name) {\r
- builder.div('class' : 'pageTitle', 'style':'color:red') {\r
- builder.span('class':'project') {\r
- mkp.yield "$type "\r
- span('class': 'repository', name )\r
- mkp.yield " deleted"\r
- }\r
- }\r
- }\r
-\r
- def commitUrl(RevCommit commit) {\r
- "${baseCommitUrl}$commit.id.name"\r
- }\r
-\r
- def commitDiffUrl(RevCommit commit) {\r
- "${baseCommitDiffUrl}$commit.id.name"\r
- }\r
-\r
- def encoded(String path) {\r
- path.replace('/', forwardSlashChar).replace('/', '%2F')\r
- }\r
-\r
- def blobDiffUrl(objectId, path) {\r
- if (mountParameters) {\r
- // REST style\r
- "${baseBlobDiffUrl}${objectId.name()}/${encoded(path)}"\r
- } else {\r
- "${baseBlobDiffUrl}${objectId.name()}&f=${path}"\r
- }\r
-\r
- }\r
-\r
- def writeCommitTable(commits, includeChangedPaths=true) {\r
- // Write commits table\r
- builder.table('class':"table table-disable-hover") {\r
- thead {\r
- tr {\r
- th(colspan: includeGravatar ? 2 : 1, "Author")\r
- th( "Commit" )\r
- th( "Message" )\r
- }\r
- }\r
- tbody() {\r
-\r
- // Write all the commits\r
- for (commit in commits) {\r
- writeCommit(commit)\r
-\r
- if (includeChangedPaths) {\r
- // Write detail on that particular commit\r
- tr('class' : 'noborder') {\r
- td (colspan: includeGravatar ? 3 : 2)\r
- td (colspan:2) { writeStatusTable(commit) }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- def writeCommit(commit) {\r
- def abbreviated = repository.newObjectReader().abbreviate(commit.id, shortCommitIdLength).name()\r
- def author = commit.authorIdent.name\r
- def email = commit.authorIdent.emailAddress\r
- def message = commit.shortMessage\r
- builder.tr {\r
- if (includeGravatar) {\r
- td('class':"gravatar-column") {\r
- img(src:gravatarUrl(email), 'class':"gravatar")\r
- }\r
- }\r
- td('class':"author-column", author)\r
- td('class':"commit-column") {\r
- a(href:commitUrl(commit)) {\r
- span('class':"label label-info", abbreviated )\r
- }\r
- }\r
- td {\r
- mkp.yield message\r
- a('class':'link', href:commitDiffUrl(commit), " [commitdiff]" )\r
- }\r
- }\r
- }\r
-\r
- def writeStatusLabel(style, tooltip) {\r
- builder.span('class' : style, 'title' : tooltip )\r
- }\r
-\r
- def writeAddStatusLine(ObjectId id, FileHeader header) { \r
- builder.td('class':'changeType') {\r
- writeStatusLabel("addition", "addition")\r
- }\r
- builder.td {\r
- a(href:blobDiffUrl(id, header.newPath), header.newPath)\r
- }\r
- }\r
-\r
- def writeCopyStatusLine(ObjectId id, FileHeader header) {\r
- builder.td('class':'changeType') {\r
- writeStatusLabel("rename", "rename")\r
- }\r
- builder.td() {\r
- a(href:blobDiffUrl(id, header.newPath), header.oldPath + " copied to " + header.newPath)\r
- }\r
- }\r
-\r
- def writeDeleteStatusLine(ObjectId id, FileHeader header) {\r
- builder.td('class':'changeType') {\r
- writeStatusLabel("deletion", "deletion")\r
- }\r
- builder.td() {\r
- a(href:blobDiffUrl(id, header.oldPath), header.oldPath)\r
- }\r
- }\r
-\r
- def writeModifyStatusLine(ObjectId id, FileHeader header) {\r
- builder.td('class':'changeType') {\r
- writeStatusLabel("modification", "modification")\r
- }\r
- builder.td() {\r
- a(href:blobDiffUrl(id, header.oldPath), header.oldPath)\r
- }\r
- }\r
-\r
- def writeRenameStatusLine(ObjectId id, FileHeader header) {\r
- builder.td('class':'changeType') {\r
- writeStatusLabel("rename", "rename")\r
- }\r
- builder.td() {\r
- mkp.yield header.oldPath\r
- mkp.yieldUnescaped "<b> -&rt; </b>"\r
- a(href:blobDiffUrl(id, header.newPath), header.newPath)\r
- }\r
- }\r
-\r
- def writeStatusLine(ObjectId id, FileHeader header) {\r
- builder.tr {\r
- switch (header.changeType) {\r
- case ChangeType.ADD:\r
- writeAddStatusLine(id, header)\r
- break;\r
- case ChangeType.COPY:\r
- writeCopyStatusLine(id, header)\r
- break;\r
- case ChangeType.DELETE:\r
- writeDeleteStatusLine(id, header)\r
- break;\r
- case ChangeType.MODIFY:\r
- writeModifyStatusLine(id, header)\r
- break;\r
- case ChangeType.RENAME:\r
- writeRenameStatusLine(id, header)\r
- break;\r
- }\r
- }\r
- }\r
-\r
- def writeStatusTable(RevCommit commit) {\r
- DiffFormatter formatter = new DiffFormatter(DisabledOutputStream.INSTANCE)\r
- formatter.setRepository(repository)\r
- formatter.setDetectRenames(true)\r
- formatter.setDiffComparator(RawTextComparator.DEFAULT);\r
-\r
- def diffs\r
- RevWalk rw = new RevWalk(repository)\r
- if (commit.parentCount > 0) {\r
- RevCommit parent = rw.parseCommit(commit.parents[0].id)\r
- diffs = formatter.scan(parent.tree, commit.tree)\r
- } else {\r
- diffs = formatter.scan(new EmptyTreeIterator(),\r
- new CanonicalTreeParser(null, rw.objectReader, commit.tree))\r
- }\r
- rw.dispose()\r
- // Write status table\r
- builder.table('class':"plain") {\r
- tbody() {\r
- for (DiffEntry entry in diffs) {\r
- FileHeader header = formatter.toFileHeader(entry)\r
- writeStatusLine(commit.id, header)\r
- }\r
- }\r
- }\r
- }\r
-\r
-\r
- def md5(text) {\r
-\r
- def digest = MessageDigest.getInstance("MD5")\r
-\r
- //Quick MD5 of text\r
- def hash = new BigInteger(1, digest.digest(text.getBytes()))\r
- .toString(16)\r
- .padLeft(32, "0")\r
- hash.toString()\r
- }\r
-\r
- def gravatarUrl(email) {\r
- def cleaned = email.trim().toLowerCase()\r
- "http://www.gravatar.com/avatar/${md5(cleaned)}?s=30"\r
- }\r
-\r
- def writeNavbar() {\r
- builder.div('class':"navbar navbar-fixed-top") {\r
- div('class':"navbar-inner") {\r
- div('class':"container") {\r
- a('class':"brand", href:"${url}", title:"GitBlit") {\r
- img(src:"${url}/gitblt_25_white.png",\r
- width:"79",\r
- height:"25",\r
- 'class':"logo")\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- def write() {\r
- builder.html {\r
- head {\r
- link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap.css")\r
- link(rel:"stylesheet", href:"${url}/gitblit.css")\r
- link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap-responsive.css")\r
- writeStyle()\r
- }\r
- body {\r
-\r
- writeNavbar()\r
-\r
- div('class':"container") {\r
-\r
- for (command in commands) {\r
- def ref = command.refName\r
- def refType = 'Branch'\r
- if (ref.startsWith('refs/heads/')) {\r
- ref = command.refName.substring('refs/heads/'.length())\r
- } else if (ref.startsWith('refs/tags/')) {\r
- ref = command.refName.substring('refs/tags/'.length())\r
- refType = 'Tag'\r
- }\r
-\r
- switch (command.type) {\r
- case ReceiveCommand.Type.CREATE:\r
- def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
- commitCount += commits.size()\r
- if (refType == 'Branch') {\r
- // new branch\r
- writeBranchTitle(refType, ref, "created", commits.size())\r
- writeCommitTable(commits, true)\r
- } else {\r
- // new tag\r
- writeBranchTitle(refType, ref, "created", 0)\r
- writeCommitTable(commits, false)\r
- }\r
- break\r
- case ReceiveCommand.Type.UPDATE:\r
- def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
- commitCount += commits.size()\r
- // fast-forward branch commits table\r
- // Write header\r
- writeBranchTitle(refType, ref, "updated", commits.size())\r
- writeCommitTable(commits)\r
- break\r
- case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:\r
- def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
- commitCount += commits.size()\r
- // non-fast-forward branch commits table\r
- // Write header\r
- writeBranchTitle(refType, ref, "updated [NON fast-forward]", commits.size())\r
- writeCommitTable(commits)\r
- break\r
- case ReceiveCommand.Type.DELETE:\r
- // deleted branch/tag\r
- writeBranchDeletedTitle(refType, ref)\r
- break\r
- default:\r
- break\r
- }\r
- }\r
- }\r
- }\r
- }\r
- writer.toString()\r
- }\r
-\r
-}\r
-\r
-def mailWriter = new HtmlMailWriter()\r
-mailWriter.repository = r\r
-mailWriter.baseCommitUrl = baseCommitUrl\r
-mailWriter.baseBlobDiffUrl = baseBlobDiffUrl\r
-mailWriter.baseCommitDiffUrl = baseCommitDiffUrl\r
-mailWriter.forwardSlashChar = forwardSlashChar\r
-mailWriter.commands = commands\r
-mailWriter.url = url\r
-mailWriter.mountParameters = GitBlit.getBoolean(Keys.web.mountParameters, true)\r
-mailWriter.includeGravatar = GitBlit.getBoolean(Keys.web.allowGravatar, true)\r
-mailWriter.shortCommitIdLength = GitBlit.getInteger(Keys.web.shortCommitIdLength, 8)\r
-\r
-def content = mailWriter.write()\r
-\r
-// close the repository reference\r
-r.close()\r
-\r
-// tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
-def repositoryName = repository.name.substring(0, repository.name.length() - 4)\r
-gitblit.sendHtmlMail("${emailprefix} ${userModel.displayName} pushed ${mailWriter.commitCount} commits => $repositoryName",\r
- content,\r
- toAddresses)\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.TeamModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import java.text.SimpleDateFormat\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.lib.Config\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-\r
-/**\r
- * Sample Gitblit Post-Receive Hook: sendmail\r
- *\r
- * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
- * to the Git repository. This is the appropriate point to trigger an\r
- * integration build or to send a notification.\r
- * \r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push. If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- *\r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- * \r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- *\r
- * If you want this hook script to fail and abort all subsequent scripts in the\r
- * chain, "return false" at the appropriate failure points.\r
- * \r
- * Bound Variables:\r
- * gitblit Gitblit Server com.gitblit.GitBlit\r
- * repository Gitblit Repository com.gitblit.models.RepositoryModel\r
- * receivePack JGit Receive Pack org.eclipse.jgit.transport.ReceivePack\r
- * user Gitblit User com.gitblit.models.UserModel\r
- * commands JGit commands Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- * url Base url for Gitblit String\r
- * logger Logs messages to Gitblit org.slf4j.Logger\r
- * clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- * def myCustomField = repository.customFields.myCustomField\r
- * \r
- */\r
-\r
-// Indicate we have started the script\r
-logger.info("sendmail hook triggered by ${user.username} for ${repository.name}")\r
-\r
-/*\r
- * Primitive email notification.\r
- * This requires the mail settings to be properly configured in Gitblit.\r
- */\r
-\r
-Repository r = gitblit.getRepository(repository.name)\r
-\r
-// reuse existing repository config settings, if available\r
-Config config = r.getConfig()\r
-def mailinglist = config.getString('hooks', null, 'mailinglist')\r
-def emailprefix = config.getString('hooks', null, 'emailprefix')\r
-\r
-// set default values\r
-def toAddresses = []\r
-if (emailprefix == null)\r
-emailprefix = '[Gitblit]'\r
-\r
-if (mailinglist != null) {\r
- def addrs = mailinglist.split(/(,|\s)/)\r
- toAddresses.addAll(addrs)\r
-}\r
-\r
-// add all mailing lists defined in gitblit.properties or web.xml\r
-toAddresses.addAll(gitblit.getStrings(Keys.mail.mailingLists))\r
-\r
-// add all team mailing lists\r
-def teams = gitblit.getRepositoryTeams(repository)\r
-for (team in teams) {\r
- TeamModel model = gitblit.getTeamModel(team)\r
- if (model.mailingLists) {\r
- toAddresses.addAll(model.mailingLists)\r
- }\r
-}\r
-\r
-// add all mailing lists for the repository\r
-toAddresses.addAll(repository.mailingLists)\r
-\r
-// define the summary and commit urls\r
-def repo = repository.name\r
-def summaryUrl\r
-def commitUrl\r
-if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
- repo = repo.replace('/', gitblit.getString(Keys.web.forwardSlashCharacter, '/')).replace('/', '%2F')\r
- summaryUrl = url + "/summary/$repo"\r
- commitUrl = url + "/commit/$repo/"\r
-} else {\r
- summaryUrl = url + "/summary?r=$repo"\r
- commitUrl = url + "/commit?r=$repo&h="\r
-}\r
-\r
-// construct a simple text summary of the changes contained in the push\r
-def branchBreak = '>---------------------------------------------------------------\n'\r
-def commitBreak = '\n\n ----\n'\r
-def commitCount = 0\r
-def changes = ''\r
-SimpleDateFormat df = new SimpleDateFormat(gitblit.getString(Keys.web.datetimestampLongFormat, 'EEEE, MMMM d, yyyy h:mm a z'))\r
-def table = { "\n ${JGitUtils.getDisplayName(it.authorIdent)}\n ${df.format(JGitUtils.getCommitDate(it))}\n\n $it.shortMessage\n\n $commitUrl$it.id.name" }\r
-for (command in commands) {\r
- def ref = command.refName\r
- def refType = 'branch'\r
- if (ref.startsWith('refs/heads/')) {\r
- ref = command.refName.substring('refs/heads/'.length())\r
- } else if (ref.startsWith('refs/tags/')) {\r
- ref = command.refName.substring('refs/tags/'.length())\r
- refType = 'tag'\r
- }\r
- \r
- switch (command.type) {\r
- case ReceiveCommand.Type.CREATE:\r
- def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
- commitCount += commits.size()\r
- // new branch\r
- changes += "\n$branchBreak new $refType $ref created ($commits.size commits)\n$branchBreak"\r
- changes += commits.collect(table).join(commitBreak)\r
- changes += '\n'\r
- break\r
- case ReceiveCommand.Type.UPDATE:\r
- def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
- commitCount += commits.size()\r
- // fast-forward branch commits table\r
- changes += "\n$branchBreak $ref $refType updated ($commits.size commits)\n$branchBreak"\r
- changes += commits.collect(table).join(commitBreak)\r
- changes += '\n'\r
- break\r
- case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:\r
- def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
- commitCount += commits.size()\r
- // non-fast-forward branch commits table\r
- changes += "\n$branchBreak $ref $refType updated [NON fast-forward] ($commits.size commits)\n$branchBreak"\r
- changes += commits.collect(table).join(commitBreak)\r
- changes += '\n'\r
- break\r
- case ReceiveCommand.Type.DELETE:\r
- // deleted branch/tag\r
- changes += "\n$branchBreak $ref $refType deleted\n$branchBreak"\r
- break\r
- default:\r
- break\r
- }\r
-}\r
-// close the repository reference\r
-r.close()\r
-\r
-// tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
-gitblit.sendMail("$emailprefix $user.username pushed $commitCount commits => $repository.name", "$summaryUrl\n$changes", toAddresses)
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright 2011 Wolfgang Gassler gassler.org\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.TeamModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import java.text.SimpleDateFormat\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.lib.Config\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-import org.eclipse.jgit.lib.IndexDiff\r
-import org.eclipse.jgit.lib.Constants\r
-import com.gitblit.utils.DiffUtils\r
-\r
-/**\r
- * Gitblit Post-Receive Hook: thebuggenie\r
- * www.thebuggenie.com\r
- * \r
- * Submit the commit information to thebuggenie bug tracker by calling thebuggenie client tool\r
- * \r
- * Config of the Script:\r
- * \r
- * Setup a custom gitblit field in the proprties file of gitblit by adding the following line\r
- * groovy.customFields = "thebuggenieProjectId=TheBugGennie project id (used for thebuggenie hoocks)"\r
- * This field allows to specify the project id of thebuggenie project in the edit section of gitblit\r
- * \r
- * Furthermore you need to set the path to thebuggenie client tool by adding the following property to\r
- * the gitblit properties file\r
- * thebuggenie.tbg_cli = /var/www/thebuggenie_root/tbg_cli\r
- */\r
-\r
-// Indicate we have started the script\r
-logger.info("thebuggenie hook triggered by ${user.username} for ${repository.name}")\r
-\r
-//fetch the repository data\r
-Repository r = gitblit.getRepository(repository.name)\r
-\r
-//get project id which is defined in the git repo metadata\r
-def tbgProjectId = repository.customFields.thebuggenieProjectId\r
-//get path to the thebuggenie client tool which is defined in the gitblit proprties files\r
-def tbgCliPath = gitblit.getString('thebuggenie.tbg_cli', '/var/www/thebuggenie/tbg_cli')\r
-def tbgCliDirPath = new File(tbgCliPath).getParent()\r
-\r
-for(command in commands) {\r
- //fetch all pushed commits\r
- def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
- for (commit in commits) {\r
- //get hashes and author data of commit\r
- def oldhash = commit.getParent(0).getId().getName()\r
- def newhash = commit.getId().getName()\r
- def authorIdent = commit.getAuthorIdent()\r
- def author = "${authorIdent.name} <${authorIdent.emailAddress}>"\r
- //fetch all changed files of the commit\r
- def files = JGitUtils.getFilesInCommit(r,commit)\r
- def changedFiles = ""\r
- for (f in files) {\r
- //transform file data to the format which is needed by thebuggenie\r
- changedFiles += f.changeType.toString().substring(0,1)+"\t${f.path}\n"\r
- }\r
- //ok let's submit all information to thebuggenie by calling the client tool\r
-// def shc = "$tbgCliPath vcs_integration:report_commit $tbgProjectId \"$author\" $newhash \"${commit.fullMessage}\" \"$changedFiles\" $oldhash ${commit.commitTime}"\r
- def shc = [tbgCliPath, "vcs_integration:report_commit", tbgProjectId, author, newhash, commit.getFullMessage(), changedFiles, oldhash, commit.getCommitTime()];\r
- logger.info("executing in path " + tbgCliDirPath + ": "+shc)\r
- shc.execute(null, new File(tbgCliDirPath))\r
- }\r
-}\r
-\r
-// close the repository reference\r
-r.close()\r
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">\r
\r
+ <!-- The base folder is used to specify the root location of your Gitblit data.\r
+ \r
+ ${baseFolder}/gitblit.properties\r
+ ${baseFolder}/users.conf\r
+ ${baseFolder}/projects.conf\r
+ ${baseFolder}/robots.txt\r
+ ${baseFolder}/git\r
+ ${baseFolder}/groovy\r
+ ${baseFolder}/groovy/grape\r
+ ${baseFolder}/proposals\r
+\r
+ By default, this location is WEB-INF/data. It is recommended to set this\r
+ path to a location outside your webapps folder that is writable by your\r
+ servlet container. Gitblit will copy the WEB-INF/data files to that\r
+ location for you when it restarts. This approach makes upgrading simpler.\r
+ All you have to do is set this parameter for the new release and then\r
+ review the defaults for any new settings. Settings are always versioned\r
+ with a SINCE x.y.z attribute and also noted in the release changelog.\r
+ -->\r
+ <context-param>\r
+ <param-name>baseFolder</param-name>\r
+ <param-value>${contextFolder}/WEB-INF/data</param-value>\r
+ </context-param>\r
+\r
<!-- PARAMS --> \r
\r
<!-- Gitblit Context Listener --><!-- STRIP \r
\r
public static final String R_GITBLIT = "refs/gitblit/";\r
\r
+ public static final String baseFolder = "baseFolder";\r
+ \r
+ public static final String baseFolder$ = "${" + baseFolder + "}";\r
+ \r
+ public static final String contextFolder$ = "${contextFolder}";\r
+ \r
public static String getGitBlitVersion() {\r
return NAME + " v" + VERSION;\r
}\r
-\r
+ \r
/**\r
* Enumeration representing the four access restriction levels.\r
*/\r
}\r
\r
// configure the Gitblit singleton for minimal, non-server operation\r
- GitBlit.self().configureContext(settings, false);\r
+ GitBlit.self().configureContext(settings, null, false);\r
FederationPullExecutor executor = new FederationPullExecutor(registrations, params.isDaemon);\r
executor.run();\r
if (!params.isDaemon) {\r
private final ObjectCache<String> projectRepositoriesMarkdownCache = new ObjectCache<String>();\r
\r
private ServletContext servletContext;\r
+ \r
+ private File baseFolder;\r
\r
private File repositoriesFolder;\r
\r
* @return the file\r
*/\r
public static File getFileOrFolder(String fileOrFolder) {\r
- String openShift = System.getenv("OPENSHIFT_DATA_DIR");\r
- if (!StringUtils.isEmpty(openShift)) {\r
- // running on RedHat OpenShift\r
- return new File(openShift, fileOrFolder);\r
- }\r
- return new File(fileOrFolder);\r
+ return com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$,\r
+ self().baseFolder, fileOrFolder);\r
}\r
\r
/**\r
* @return the repositories folder path\r
*/\r
public static File getRepositoriesFolder() {\r
- return getFileOrFolder(Keys.git.repositoriesFolder, "git");\r
+ return getFileOrFolder(Keys.git.repositoriesFolder, "${baseFolder}/git");\r
}\r
\r
/**\r
* @return the proposals folder path\r
*/\r
public static File getProposalsFolder() {\r
- return getFileOrFolder(Keys.federation.proposalsFolder, "proposals");\r
+ return getFileOrFolder(Keys.federation.proposalsFolder, "${baseFolder}/proposals");\r
}\r
\r
/**\r
* @return the Groovy scripts folder path\r
*/\r
public static File getGroovyScriptsFolder() {\r
- return getFileOrFolder(Keys.groovy.scriptsFolder, "groovy");\r
+ return getFileOrFolder(Keys.groovy.scriptsFolder, "${baseFolder}/groovy");\r
}\r
-\r
+ \r
/**\r
* Updates the list of server settings.\r
* \r
}\r
RepositoryModel model = new RepositoryModel();\r
model.isBare = r.isBare();\r
- File basePath = getFileOrFolder(Keys.git.repositoriesFolder, "git");\r
+ File basePath = getFileOrFolder(Keys.git.repositoriesFolder, "${baseFolder}/git");\r
if (model.isBare) {\r
model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory());\r
} else {\r
* \r
* @param settings\r
*/\r
- public void configureContext(IStoredSettings settings, boolean startFederation) {\r
- logger.info("Reading configuration from " + settings.toString());\r
+ public void configureContext(IStoredSettings settings, File folder, boolean startFederation) {\r
this.settings = settings;\r
+ this.baseFolder = folder;\r
\r
repositoriesFolder = getRepositoriesFolder();\r
- logger.info("Git repositories folder " + repositoriesFolder.getAbsolutePath());\r
+\r
+ logger.info("Gitblit base folder = " + folder.getAbsolutePath());\r
+ logger.info("Git repositories folder = " + repositoriesFolder.getAbsolutePath());\r
+ logger.info("Gitblit settings = " + settings.toString());\r
\r
// prepare service executors\r
mailExecutor = new MailExecutor(settings);\r
serverStatus = new ServerStatus(isGO());\r
\r
if (this.userService == null) {\r
- String realm = settings.getString(Keys.realm.userService, "users.properties");\r
+ String realm = settings.getString(Keys.realm.userService, "${baseFolder}/users.properties");\r
IUserService loginService = null;\r
try {\r
// check to see if this "file" is a login service class\r
}\r
\r
// load and cache the project metadata\r
- projectConfigs = new FileBasedConfig(getFileOrFolder(Keys.web.projectsFile, "projects.conf"), FS.detect());\r
+ projectConfigs = new FileBasedConfig(getFileOrFolder(Keys.web.projectsFile, "${baseFolder}/projects.conf"), FS.detect());\r
getProjectConfigs();\r
\r
// schedule mail engine\r
public void contextInitialized(ServletContextEvent contextEvent, InputStream referencePropertiesInputStream) {\r
servletContext = contextEvent.getServletContext();\r
if (settings == null) {\r
- // Gitblit WAR is running in a servlet container\r
+ // Gitblit is running in a servlet container\r
ServletContext context = contextEvent.getServletContext();\r
WebXmlSettings webxmlSettings = new WebXmlSettings(context);\r
-\r
- // gitblit.properties file located within the webapp\r
- String webProps = context.getRealPath("/WEB-INF/gitblit.properties");\r
- if (!StringUtils.isEmpty(webProps)) {\r
- File overrideFile = new File(webProps);\r
- webxmlSettings.applyOverrides(overrideFile);\r
- }\r
+ File contextFolder = new File(context.getRealPath("/"));\r
+ String openShift = System.getenv("OPENSHIFT_DATA_DIR");\r
\r
- // gitblit.properties file located outside the deployed war\r
- // folder lie, for example, on RedHat OpenShift.\r
- File overrideFile = getFileOrFolder("gitblit.properties");\r
- if (!overrideFile.getPath().equals("gitblit.properties")) {\r
+ if (!StringUtils.isEmpty(openShift)) {\r
+ // Gitblit is running in OpenShift/JBoss\r
+ File base = new File(openShift);\r
+\r
+ // gitblit.properties setting overrides\r
+ File overrideFile = new File(base, "gitblit.properties");\r
webxmlSettings.applyOverrides(overrideFile);\r
- }\r
- \r
- configureContext(webxmlSettings, true);\r
-\r
- // Copy the included scripts to the configured groovy folder\r
- File localScripts = getFileOrFolder(Keys.groovy.scriptsFolder, "groovy");\r
- if (!localScripts.exists()) {\r
- File includedScripts = new File(context.getRealPath("/WEB-INF/groovy"));\r
- if (!includedScripts.equals(localScripts)) {\r
- try {\r
- com.gitblit.utils.FileUtils.copy(localScripts, includedScripts.listFiles());\r
- } catch (IOException e) {\r
- logger.error(MessageFormat.format(\r
- "Failed to copy included Groovy scripts from {0} to {1}",\r
- includedScripts, localScripts));\r
+ \r
+ // Copy the included scripts to the configured groovy folder\r
+ File localScripts = new File(base, webxmlSettings.getString(Keys.groovy.scriptsFolder, "groovy"));\r
+ if (!localScripts.exists()) {\r
+ File warScripts = new File(contextFolder, "/WEB-INF/data/groovy");\r
+ if (!warScripts.equals(localScripts)) {\r
+ try {\r
+ com.gitblit.utils.FileUtils.copy(localScripts, warScripts.listFiles());\r
+ } catch (IOException e) {\r
+ logger.error(MessageFormat.format(\r
+ "Failed to copy included Groovy scripts from {0} to {1}",\r
+ warScripts, localScripts));\r
+ }\r
}\r
}\r
+ \r
+ // configure context using the web.xml\r
+ configureContext(webxmlSettings, base, true);\r
+ } else {\r
+ // Gitblit is running in a standard servlet container\r
+ logger.info("WAR contextFolder is " + contextFolder.getAbsolutePath());\r
+ \r
+ String path = webxmlSettings.getString(Constants.baseFolder, Constants.contextFolder$ + "/WEB-INF/data");\r
+ File base = com.gitblit.utils.FileUtils.resolveParameter(Constants.contextFolder$, contextFolder, path);\r
+ base.mkdirs();\r
+ \r
+ // try to copy the data folder contents to the baseFolder\r
+ File localSettings = new File(base, "gitblit.properties");\r
+ if (!localSettings.exists()) {\r
+ File contextData = new File(contextFolder, "/WEB-INF/data");\r
+ if (!base.equals(contextData)) {\r
+ try {\r
+ com.gitblit.utils.FileUtils.copy(base, contextData.listFiles());\r
+ } catch (IOException e) {\r
+ logger.error(MessageFormat.format(\r
+ "Failed to copy included data from {0} to {1}",\r
+ contextData, base));\r
+ }\r
+ }\r
+ }\r
+ \r
+ // delegate all config to baseFolder/gitblit.properties file\r
+ FileSettings settings = new FileSettings(localSettings.getAbsolutePath()); \r
+ configureContext(settings, base, true);\r
}\r
}\r
\r
private static Logger logger;\r
\r
public static void main(String... args) {\r
+ // filter out the baseFolder parameter\r
+ List<String> filtered = new ArrayList<String>();\r
+ String folder = "data";\r
+ for (int i = 0; i< args.length; i++) {\r
+ String arg = args[i];\r
+ if (arg.equals("--baseFolder")) {\r
+ if (i + 1 == args.length) {\r
+ System.out.println("Invalid --baseFolder parameter!");\r
+ System.exit(-1);\r
+ } else if (args[i + 1] != ".") {\r
+ folder = args[i + 1];\r
+ }\r
+ i = i + 1;\r
+ } else {\r
+ filtered.add(arg);\r
+ }\r
+ }\r
+ \r
+ Params.baseFolder = folder;\r
Params params = new Params();\r
JCommander jc = new JCommander(params);\r
try {\r
- jc.parse(args);\r
+ jc.parse(filtered.toArray(new String[filtered.size()]));\r
if (params.help) {\r
usage(jc, null);\r
}\r
* Start Gitblit GO.\r
*/\r
private static void start(Params params) {\r
- FileSettings settings = Params.FILESETTINGS;\r
+ final File baseFolder = new File(Params.baseFolder).getAbsoluteFile();\r
+ FileSettings settings = params.FILESETTINGS;\r
if (!StringUtils.isEmpty(params.settingsfile)) {\r
if (new File(params.settingsfile).exists()) {\r
settings = new FileSettings(params.settingsfile); \r
}\r
}\r
-\r
logger = LoggerFactory.getLogger(GitBlitServer.class);\r
logger.info(Constants.BORDER);\r
logger.info(" _____ _ _ _ _ _ _");\r
\r
// conditionally configure the https connector\r
if (params.securePort > 0) {\r
- final File folder = new File(System.getProperty("user.dir"));\r
- File certificatesConf = new File(folder, X509Utils.CA_CONFIG);\r
- File serverKeyStore = new File(folder, X509Utils.SERVER_KEY_STORE);\r
- File serverTrustStore = new File(folder, X509Utils.SERVER_TRUST_STORE);\r
- File caRevocationList = new File(folder, X509Utils.CA_REVOCATION_LIST);\r
+ File certificatesConf = new File(baseFolder, X509Utils.CA_CONFIG);\r
+ File serverKeyStore = new File(baseFolder, X509Utils.SERVER_KEY_STORE);\r
+ File serverTrustStore = new File(baseFolder, X509Utils.SERVER_TRUST_STORE);\r
+ File caRevocationList = new File(baseFolder, X509Utils.CA_REVOCATION_LIST);\r
\r
// generate CA & web certificates, create certificate stores\r
X509Metadata metadata = new X509Metadata("localhost", params.storePassword);\r
}\r
\r
metadata.notAfter = new Date(System.currentTimeMillis() + 10*TimeUtils.ONEYEAR);\r
- X509Utils.prepareX509Infrastructure(metadata, folder, new X509Log() {\r
+ X509Utils.prepareX509Infrastructure(metadata, baseFolder, new X509Log() {\r
@Override\r
public void log(String message) {\r
BufferedWriter writer = null;\r
try {\r
- writer = new BufferedWriter(new FileWriter(new File(folder, X509Utils.CERTS + File.separator + "log.txt"), true));\r
+ writer = new BufferedWriter(new FileWriter(new File(baseFolder, X509Utils.CERTS + File.separator + "log.txt"), true));\r
writer.write(MessageFormat.format("{0,date,yyyy-MM-dd HH:mm}: {1}", new Date(), message));\r
writer.newLine();\r
writer.flush();\r
\r
// tempDir is where the embedded Gitblit web application is expanded and\r
// where Jetty creates any necessary temporary files\r
- File tempDir = new File(params.temp);\r
+ File tempDir = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.temp); \r
if (tempDir.exists()) {\r
try {\r
FileUtils.delete(tempDir, FileUtils.RECURSIVE | FileUtils.RETRY);\r
\r
// Setup the GitBlit context\r
GitBlit gitblit = GitBlit.self();\r
- gitblit.configureContext(settings, true);\r
+ gitblit.configureContext(settings, baseFolder, true);\r
rootContext.addEventListener(gitblit);\r
\r
try {\r
@Parameters(separators = " ")\r
private static class Params {\r
\r
- private static final FileSettings FILESETTINGS = new FileSettings(Constants.PROPERTIES_FILE);\r
+ public static String baseFolder;\r
+\r
+ private final FileSettings FILESETTINGS = new FileSettings(new File(baseFolder, Constants.PROPERTIES_FILE).getAbsolutePath());\r
\r
/*\r
* Server parameters\r
*/\r
@Parameter(names = { "--repositoriesFolder" }, description = "Git Repositories Folder")\r
public String repositoriesFolder = FILESETTINGS.getString(Keys.git.repositoriesFolder,\r
- "repos");\r
+ "git");\r
\r
/*\r
* Authentication Parameters\r
*/\r
@Parameter(names = { "--userService" }, description = "Authentication and Authorization Service (filename or fully qualified classname)")\r
public String userService = FILESETTINGS.getString(Keys.realm.userService,\r
- "users.properties");\r
+ "users.conf");\r
\r
/*\r
* JETTY Parameters\r
public Boolean useNIO = FILESETTINGS.getBoolean(Keys.server.useNio, true);\r
\r
@Parameter(names = "--httpPort", description = "HTTP port for to serve. (port <= 0 will disable this connector)")\r
- public Integer port = FILESETTINGS.getInteger(Keys.server.httpPort, 80);\r
+ public Integer port = FILESETTINGS.getInteger(Keys.server.httpPort, 0);\r
\r
@Parameter(names = "--httpsPort", description = "HTTPS port to serve. (port <= 0 will disable this connector)")\r
- public Integer securePort = FILESETTINGS.getInteger(Keys.server.httpsPort, 443);\r
+ public Integer securePort = FILESETTINGS.getInteger(Keys.server.httpsPort, 8443);\r
\r
@Parameter(names = "--ajpPort", description = "AJP port to serve. (port <= 0 will disable this connector)")\r
public Integer ajpPort = FILESETTINGS.getInteger(Keys.server.ajpPort, 0);\r
groovyDir = GitBlit.getGroovyScriptsFolder();\r
try {\r
// set Grape root\r
- File grapeRoot = new File(GitBlit.getString(Keys.groovy.grapeFolder, "groovy/grape")).getAbsoluteFile();\r
+ File grapeRoot = GitBlit.getFileOrFolder(Keys.groovy.grapeFolder, "${baseFolder}/groovy/grape").getAbsoluteFile();\r
grapeRoot.mkdirs();\r
System.setProperty("grape.root", grapeRoot.getAbsolutePath());\r
\r
\r
@Override\r
public void setup(IStoredSettings settings) {\r
- File realmFile = GitBlit.getFileOrFolder(Keys.realm.userService, "users.conf");\r
+ File realmFile = GitBlit.getFileOrFolder(Keys.realm.userService, "${baseFolder}/users.conf");\r
serviceImpl = createUserService(realmFile);\r
logger.info("GUS delegating to " + serviceImpl.toString());\r
}\r
@Override\r
public void setup(IStoredSettings settings) {\r
this.settings = settings;\r
- String file = settings.getString(Keys.realm.ldap.backingUserService, "users.conf");\r
+ String file = settings.getString(Keys.realm.ldap.backingUserService, "${baseFolder}/users.conf");\r
File realmFile = GitBlit.getFileOrFolder(file);\r
\r
serviceImpl = createUserService(realmFile);\r
public void setup(IStoredSettings settings) {\r
this.settings = settings;\r
\r
- String file = settings.getString(Keys.realm.redmine.backingUserService, "users.conf");\r
+ String file = settings.getString(Keys.realm.redmine.backingUserService, "${baseFolder}/users.conf");\r
File realmFile = GitBlit.getFileOrFolder(file);\r
\r
serviceImpl = createUserService(realmFile);\r
import javax.servlet.http.HttpServletResponse;\r
\r
import com.gitblit.utils.FileUtils;\r
-import com.gitblit.utils.StringUtils;\r
\r
/**\r
* Handles requests for robots.txt\r
protected void processRequest(javax.servlet.http.HttpServletRequest request,\r
javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException,\r
java.io.IOException {\r
- String robotstxt = GitBlit.getString(Keys.web.robots.txt, null); \r
+ File file = GitBlit.getFileOrFolder(Keys.web.robots.txt, null);\r
String content = "";\r
- if (!StringUtils.isEmpty(robotstxt)) {\r
- File robotsfile = new File(robotstxt);\r
- if (robotsfile.exists()) {\r
- content = FileUtils.readContent(robotsfile, "\n");\r
- }\r
+ if (file.exists()) {\r
+ content = FileUtils.readContent(file, "\n");\r
}\r
response.getWriter().append(content);\r
}\r
private JButton newSSLCertificate;\r
\r
public static void main(String... args) {\r
+ // filter out the baseFolder parameter\r
+ String folder = "data";\r
+ for (int i = 0; i< args.length; i++) {\r
+ String arg = args[i];\r
+ if (arg.equals("--baseFolder")) {\r
+ if (i + 1 == args.length) {\r
+ System.out.println("Invalid --baseFolder parameter!");\r
+ System.exit(-1);\r
+ } else if (args[i + 1] != ".") {\r
+ folder = args[i+1];\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ final String baseFolder = folder;\r
EventQueue.invokeLater(new Runnable() {\r
public void run() {\r
try {\r
} catch (Exception e) {\r
}\r
GitblitAuthority authority = new GitblitAuthority();\r
- authority.initialize();\r
+ authority.initialize(baseFolder);\r
authority.setLocationRelativeTo(null);\r
authority.setVisible(true);\r
}\r
defaultSorter = new TableRowSorter<UserCertificateTableModel>(tableModel);\r
}\r
\r
- public void initialize() {\r
+ public void initialize(String baseFolder) {\r
setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());\r
setTitle("Gitblit Certificate Authority v" + Constants.VERSION + " (" + Constants.VERSION_DATE + ")");\r
setContentPane(getUI());\r
}\r
}); \r
\r
- setSizeAndPosition();\r
- \r
- File folder = new File(System.getProperty("user.dir"));\r
+ File folder = new File(baseFolder).getAbsoluteFile();\r
load(folder);\r
+ \r
+ setSizeAndPosition();\r
}\r
\r
private void setSizeAndPosition() {\r
}\r
\r
private StoredConfig getConfig() throws IOException, ConfigInvalidException {\r
- File configFile = new File(System.getProperty("user.dir"), X509Utils.CA_CONFIG);\r
+ File configFile = new File(folder, X509Utils.CA_CONFIG);\r
FileBasedConfig config = new FileBasedConfig(configFile, FS.detect());\r
config.load();\r
return config;\r
}\r
gitblitSettings = new FileSettings(file.getAbsolutePath());\r
mail = new MailExecutor(gitblitSettings);\r
- String us = gitblitSettings.getString(Keys.realm.userService, "users.conf");\r
+ String us = gitblitSettings.getString(Keys.realm.userService, "${baseFolder}/users.conf");\r
String ext = us.substring(us.lastIndexOf(".") + 1).toLowerCase();\r
IUserService service = null;\r
if (!ext.equals("conf") && !ext.equals("properties")) {\r
if (us.equals("com.gitblit.LdapUserService")) {\r
- us = gitblitSettings.getString(Keys.realm.ldap.backingUserService, "users.conf"); \r
+ us = gitblitSettings.getString(Keys.realm.ldap.backingUserService, "${baseFolder}/users.conf"); \r
} else if (us.equals("com.gitblit.LdapUserService")) {\r
- us = gitblitSettings.getString(Keys.realm.redmine.backingUserService, "users.conf");\r
+ us = gitblitSettings.getString(Keys.realm.redmine.backingUserService, "${baseFolder}/users.conf");\r
}\r
}\r
\r
if (us.endsWith(".conf")) {\r
- service = new ConfigUserService(new File(us));\r
+ service = new ConfigUserService(FileUtils.resolveParameter(Constants.baseFolder$, folder, us));\r
} else {\r
throw new RuntimeException("Unsupported user service: " + us);\r
}\r
\r
- service = new ConfigUserService(new File(us));\r
+ service = new ConfigUserService(FileUtils.resolveParameter(Constants.baseFolder$, folder, us));\r
return service;\r
}\r
\r
private void load(File folder) {\r
this.folder = folder;\r
this.userService = loadUsers(folder);\r
+ System.out.println(Constants.baseFolder$ + " set to " + folder);\r
if (userService == null) {\r
JOptionPane.showMessageDialog(this, MessageFormat.format("Sorry, {0} doesn't look like a Gitblit GO installation.", folder));\r
} else {\r
Properties properties = new Properties();\r
FileInputStream is = null;\r
try {\r
- is = new FileInputStream(Constants.PROPERTIES_FILE);\r
+ is = new FileInputStream(new File("distrib", Constants.PROPERTIES_FILE));\r
properties.load(is);\r
} catch (Throwable t) {\r
t.printStackTrace();\r
}\r
\r
private static void generateWebXml(Params params) throws Exception {\r
+ StringBuilder parameters = new StringBuilder();\r
// Read the current Gitblit properties\r
- BufferedReader propertiesReader = new BufferedReader(new FileReader(new File(\r
- params.propertiesFile)));\r
-\r
- Vector<Setting> settings = new Vector<Setting>();\r
- List<String> comments = new ArrayList<String>();\r
- String line = null;\r
- while ((line = propertiesReader.readLine()) != null) {\r
- if (line.length() == 0) {\r
- comments.clear();\r
- } else {\r
- if (line.charAt(0) == '#') {\r
- if (line.length() > 1) {\r
- comments.add(line.substring(1).trim());\r
- }\r
+ if (params.propertiesFile != null) {\r
+ BufferedReader propertiesReader = new BufferedReader(new FileReader(new File(\r
+ params.propertiesFile)));\r
+\r
+ Vector<Setting> settings = new Vector<Setting>();\r
+ List<String> comments = new ArrayList<String>();\r
+ String line = null;\r
+ while ((line = propertiesReader.readLine()) != null) {\r
+ if (line.length() == 0) {\r
+ comments.clear();\r
} else {\r
- String[] kvp = line.split("=", 2);\r
- String key = kvp[0].trim();\r
- if (!skipKey(key)) {\r
- Setting s = new Setting(key, kvp[1].trim(), comments);\r
- settings.add(s);\r
+ if (line.charAt(0) == '#') {\r
+ if (line.length() > 1) {\r
+ comments.add(line.substring(1).trim());\r
+ }\r
+ } else {\r
+ String[] kvp = line.split("=", 2);\r
+ String key = kvp[0].trim();\r
+ if (!skipKey(key)) {\r
+ Setting s = new Setting(key, kvp[1].trim(), comments);\r
+ settings.add(s);\r
+ }\r
+ comments.clear();\r
}\r
- comments.clear();\r
}\r
}\r
- }\r
- propertiesReader.close();\r
+ propertiesReader.close();\r
\r
- StringBuilder parameters = new StringBuilder();\r
-\r
- for (Setting setting : settings) {\r
- for (String comment : setting.comments) {\r
- parameters.append(MessageFormat.format(COMMENT_PATTERN, comment));\r
+ for (Setting setting : settings) {\r
+ for (String comment : setting.comments) {\r
+ parameters.append(MessageFormat.format(COMMENT_PATTERN, comment));\r
+ }\r
+ parameters.append(MessageFormat.format(PARAM_PATTERN, setting.name,\r
+ StringUtils.escapeForHtml(setting.value, false)));\r
}\r
- parameters.append(MessageFormat.format(PARAM_PATTERN, setting.name,\r
- StringUtils.escapeForHtml(setting.value, false)));\r
}\r
-\r
// Read the prototype web.xml file\r
File webxml = new File(params.sourceFile);\r
char[] buffer = new char[(int) webxml.length()];\r
@Parameter(names = { "--sourceFile" }, description = "Source web.xml file", required = true)\r
public String sourceFile;\r
\r
- @Parameter(names = { "--propertiesFile" }, description = "Properties settings file", required = true)\r
+ @Parameter(names = { "--propertiesFile" }, description = "Properties settings file")\r
public String propertiesFile;\r
\r
@Parameter(names = { "--destinationFile" }, description = "Destination web.xml file", required = true)\r
public String destinationFile;\r
-\r
+ \r
}\r
}\r
return path.getAbsoluteFile();\r
}\r
}\r
+\r
+ public static File resolveParameter(String parameter, File aFolder, String path) {\r
+ if (aFolder == null) {\r
+ // strip any parameter reference \r
+ path = path.replace(parameter, "").trim();\r
+ if (path.length() > 0 && path.charAt(0) == '/') {\r
+ // strip leading /\r
+ path = path.substring(1);\r
+ }\r
+ } else if (path.contains(parameter)) {\r
+ // replace parameter with path\r
+ path = path.replace(parameter, aFolder.getAbsolutePath());\r
+ }\r
+ return new File(path);\r
+ }\r
}\r
UserModel user = GitBlitWebSession.get().getUser(); \r
if (!GitBlit.self().supportsCredentialChanges(user)) {\r
error(MessageFormat.format(getString("gb.userServiceDoesNotPermitPasswordChanges"),\r
- GitBlit.getString(Keys.realm.userService, "users.conf")), true);\r
+ GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);\r
}\r
\r
setupPage(getString("gb.changePassword"), user.username);\r
super();\r
if (!GitBlit.self().supportsAddUser()) {\r
error(MessageFormat.format(getString("gb.userServiceDoesNotPermitAddUser"),\r
- GitBlit.getString(Keys.realm.userService, "users.conf")), true);\r
+ GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);\r
}\r
isCreate = true;\r
setupPage(new UserModel(""));\r
} else {\r
// Read user-supplied message\r
if (!StringUtils.isEmpty(messageSource)) {\r
- File file = new File(messageSource);\r
+ File file = GitBlit.getFileOrFolder(messageSource);\r
if (file.exists()) {\r
try {\r
FileInputStream fis = new FileInputStream(file);\r
# Gitblit Unit Testing properties
#
-git.repositoriesFolder = git
+git.repositoriesFolder = ${baseFolder}/git
git.searchRepositoriesSubfolders = true
git.enableGitServlet = true
-groovy.scriptsFolder = groovy
+groovy.scriptsFolder = ${baseFolder}/groovy
groovy.preReceiveScripts = blockpush
groovy.postReceiveScripts = sendmail
web.authenticateViewPages = false
#federation.example1.mirror = true
#federation.example1.mergeAccounts = true
-server.tempFolder = temp
+server.tempFolder = ${baseFolder}/temp
server.useNio = true
server.contextPath = /
server.httpPort = 0
FanoutServiceTest.class })\r
public class GitBlitSuite {\r
\r
- public static final File REPOSITORIES = new File("git");\r
+ public static final File REPOSITORIES = new File("data/git");\r
\r
static int port = 8280;\r
static int shutdownPort = 8281;\r
GitBlitServer.main("--httpPort", "" + port, "--httpsPort", "0", "--shutdownPort",\r
"" + shutdownPort, "--repositoriesFolder",\r
"\"" + GitBlitSuite.REPOSITORIES.getAbsolutePath() + "\"", "--userService",\r
- "test-users.conf", "--settings", "test-gitblit.properties");\r
+ "test-users.conf", "--settings", "test-gitblit.properties",\r
+ "--baseFolder", "data");\r
}\r
});\r
\r
assertEquals(5, settings.getInteger("realm.realmFile", 5));\r
\r
assertTrue(settings.getBoolean("git.enableGitServlet", false));\r
- assertEquals("users.conf", settings.getString("realm.userService", null));\r
+ assertEquals("${baseFolder}/users.conf", settings.getString("realm.userService", null));\r
assertEquals(5, settings.getInteger("realm.minPasswordLength", 0));\r
List<String> mdExtensions = settings.getStrings("web.markdownExtensions");\r
assertTrue(mdExtensions.size() > 0);\r