A GitBucket plugin that provides Maven repository hosting on GitBucket
Branch: master
Clone or download
Latest commit 6d71427 Dec 12, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project Update for changes in GitBucket 4.30.0 Nov 10, 2018
src/main Bump to GitBucket 4.30.0 Dec 12, 2018
.gitignore first commit Oct 17, 2017
.travis.yml Update for changes in GitBucket 4.30.0 Nov 10, 2018
README.md Update README.md Dec 12, 2018
build.sbt Bump to GitBucket 4.30.0 Dec 12, 2018
maven-repository-settings.png Update image Mar 2, 2018

README.md

gitbucket-maven-repository-plugin

A GitBucket plugin that provides Maven repository hosting on GitBucket.

Features

In default, following Maven repositories become available by installing this plugin to GitBucket.

  • http(s)://GITBUCKET_HOST/maven/releases
  • http(s)://GITBUCKET_HOST/maven/snapshots

You can deploy artifacts to these repositories via WebDAV with your GitBucket account.

Also you can deploy via SSH (SCP) with public key authentication using keys registered in GitBucket. In this case, use following configurations to connect via SSH:

  • Host: Hostname of GitBucket
  • Port: SSH port configured in GitBucket system settings
  • Path: /maven/releases or /maven/snapshots

It's possible to add more repositories and configure them at the administration console:

Maven repository settings

You can specify whether artifacts are overwritable for each repository. In addition, it's possible to make repository private. Private repositories require basic authentication by GitBucket account to access.

Compatibility

Plugin version GitBucket version
1.4.x 4.30.x -
1.3.x - 4.23.x -
1.1.x - 1.2.x 4.21.x -
1.0.x 4.19.x -

Installation

Download jar file from plugin registry and put into GITBUCKET_HOME/plugins.

Build

Run sbt assembly and copy generated /target/scala-2.12/gitbucket-maven-repository-plugin-assembly-x.x.x.jar to ~/.gitbucket/plugins/ (If the directory does not exist, create it by hand before copying the jar), or just run sbt install.

Configuration

sbt

Resolvers:

resolvers ++= Seq(
 "GitBucket Snapshots Repository" at "http://localhost:8080/maven/snapshots",
 "GitBucket Releases Repository"  at "http://localhost:8080/maven/releases"
)

// If repository is private, you have to add authentication information
credentials += Credentials("GitBucket Maven Repository", "localhost", "username", "password")

Publish via WebDAV:

publishTo := {
  val base = "http://localhost:8080/maven/"
  if (version.value.endsWith("SNAPSHOT")) Some("snapshots" at base + "snapshots")
  else                                    Some("releases"  at base + "releases")
}

credentials += Credentials("GitBucket Maven Repository", "localhost", "username", "password")

Publish via SSH:

publishTo := {
  val repoInfo =
    if (version.value.endsWith("SNAPSHOT")) ("snapshots" -> "/maven/snapshots")
    else                                    ("releases"  -> "/maven/releases")
  Some(Resolver.ssh(repoInfo._1, "localhost", 29418, repoInfo._2) 
    as(System.getProperty("user.name"), (Path.userHome / ".ssh" / "id_rsa").asFile))
}

Maven

Add distribution settings to your pom.xml:

<project>
  ...
  <distributionManagement>
    <repository>
      <id>gitbucket-maven-repository-releases</id>
      <url>http://localhost:8080/maven/releases</url>
    </repository>
    <snapshotRepository>
      <id>gitbucket-maven-repository-snapshots</id>
      <url>http://localhost:8080/maven/snapshots</url>
    </snapshotRepository>
  </distributionManagement>
  ...
</project>

Also you need to add authentication settings in ~/.m2/settings.xml (replace username and password with your GitBucket account's one):

<settings>
  ...
  <servers>
    <server>
      <id>gitbucket-maven-repository-releases</id>
      <username>root</username>
      <password>root</password>
    </server>
    <server>
      <id>gitbucket-maven-repository-snapshots</id>
      <username>root</username>
      <password>root</password>
    </server>
  </servers>
   ...
</settings>