commit | b2bc6ca5b18e4cb617a9e28e4cffa7f8b94ba150 | [log] [tgz] |
---|---|---|
author | Marco Miller <marco.miller@ericsson.com> | Sun Mar 31 10:55:20 2019 -0400 |
committer | Marco Miller <marco.miller@ericsson.com> | Sun Mar 31 10:59:38 2019 -0400 |
tree | 98143c69363ce394546a548d0d955f9320314f9b | |
parent | 1ddd5491b220cae9b7c3919ba9c08e9c31217a14 [diff] | |
parent | ae3bda056cfce7abad76fa4b35c742f794e388c1 [diff] |
Merge branch 'stable-2.16' * stable-2.16: Upgrade bazlets to latest stable-2.16 to build with 2.16.7 API Upgrade bazlets to latest stable-2.15 to build with 2.15.12 API Upgrade bazlets to latest stable-2.14 to build with 2.14.19 API Maven: Build with 2.15.11 Upgrade bazlets to latest stable-2.15 Upgrade bazlets to latest stable-2.14 Update bazlets to fix build with bazel 0.23 Upgrade bazlets to latest stable-2.15 to build with 2.15.11 API WORKSPACE: Make heading comment space indent consistent Maven: Build with Gerrit 2.15.10 API Upgrade bazlets to latest stable-2.15 to build with 2.15.10 API Upgrade bazlets to latest stable-2.15 to build with 2.15.9 API Maven: Build with 2.15.8 API Upgrade bazlets to latest stable-2.15 to build with 2.15.8 API Maven: Build with 2.14.18 API Upgrade bazlets to latest stable-2.14 to build with 2.14.18 API Bazel: Include eclipse-out directory in .bazelignore Bazel: Migrate `tools/bazel.rc` to `.bazelrc` Upgrade bazlets to latest stable-2.15 to build with 2.15.7 API Upgrade bazlets to latest stable-2.14 to build with 2.14.17 API PublishEventListener: Don't hard-code "All-Projects" PublishEventListener: Inject PluginConfigFactory via constructor UnsupportedMessageGenerator: Remove unused ProjectConfig member Maven: Build with API 2.15.6 Maven: Build with API 2.14.16 Upgrade bazlets to latest stable-2.15 to build with 2.15.6 API WORKSPACE: Replace custom local_path with template WORKSPACE: Replace custom local_path with template Upgrade bazlets to latest stable-2.14 to build with 2.14.16 API WebhookClient: Add missing @Override annotation Open auto-closeable resources in try-with-resource Align Eclipse compiler settings with core Gerrit's bazlets: Replace native.git_repository with skylark rule Maven: Format pom.xml with xmllint Maven: Remove commented-out plugins Maven: Upgrade maven-compiler-plugin to 3.8.0 Maven: Build with 2.14.15 API bazlets: Replace native.git_repository with skylark rule Format all Bazel build files with buildifier Format all Java files with google-java-format Format all Bazel build files with buildifier Format all Java files with google-java-format Upgrade bazlets to latest stable-2.15 to build with 2.15.5 API Upgrade bazlets to latest stable-2.14 to build with 2.14.15 API Maven: Build with 2.14.13 API Bazel: Migrate `tools/bazel.rc` to `.bazelrc` Bazel: Update bazlets to latest stable-2.14 to build with 2.14.13 API Restores missing proxy config assignments Adds proxy support Adds proxy support Maven: Upgrade maven-jar-plugin to 3.1.0 Maven: Build with 2.14.8 API Bazel: Upgrade bazlets to latest stable-2.14 revision to use 2.14.8 API Format all Java files with google-java-format Optionally ignore wip/private patch sets and notify on state change Bazel: Update bazlets to latest stable-2.15 to use 2.15-rc3 API Format WORKSPACE with buildifier Format all Java files with google-java-format Format WORKSPACE with buildifier Add Bazel build WebhookClient: Simplify getResponse method WebhookClient: Simplify getResponse method Add Bazel build Build with 2.14.7 API Add Eclipse generated files to .gitignore Add Eclipse generated files to .gitignore Upgrade maven-compiler-plugin to 3.7.0 and build with Java 8 Upgrade maven-compiler-plugin to 3.7.0 and build with Java 8 Build with API version 2.14.6 Ignore no code change and rebase patch sets Update API dependency to 2.15-rc3 Puts more emphasis on the commit title in published messages Updates unit tests for fallback message changes Adds commit message to the attachment fallback Reworks message generation Change-Id: I705de7a3fc52f60fc991dfc5c5762abcef21aaf6
A simple Gerrit plugin that allows the publishing of certain Gerrit events to a configured Slack Webhook URL. The plugin uses Gerrit's inherited project configuration support so common config options can be set at a higher level and shared by many projects along with project specific config options.
To build the plugin, JDK 1.8, Maven 3.0.x and Ant 1.9.x are required. Once installed use mvn to build.
cd ./slack-integration mvn install
This command will compile/test and package the resulting artifact.
cd ./slack-integration mvn package
Once packaged, you can install the ./target/slack-integration.jar file into Gerrit.
Installing the Slack Integration Plugin is as simple as copying the resulting JAR file into the Gerrit plugins directory. Assuming you installation of Gerrit is located at /usr/local/gerrit you simply execute the following.
cp ./slack-integration.jar /usr/local/gerrit/plugins
Simple substitute the path to your Gerrit plugins directory as needed. Gerrit automatically loads new plugins and unloads old plugins, no restart is required.
The first thing you need to do is setup an incoming webhook integration in Slack. This is done via my.slack.com - Configure Integrations.
Configuration of the Slack Integration Plugin is done in Gerrit via a project specific config file. This configuration is stored in the project’s project.config file on the refs/meta/config branch of the project.
Common configuration options that can be shared between multiple projects can be placed in the All-Projects config branch, or another project that serves as an inherited base. Config options can then be overridden in the actual project's config branch. For example, you may want to specify a default webhook URL, username and channel then override the channel to be specific to each project.
Editing a project's config
mkdir <project>-config cd <project>-config git init git remote add origin ssh://<admin-user>@<gerrit-host>:29418/<project> git fetch origin refs/meta/config:refs/remotes/origin/meta/config git checkout meta/config
Create the following config block
vi project.config [plugin "slack-integration"] enabled = true webhookurl = https://<web-hook-url> channel = general username = gerrit ignore = "^WIP.*"
Commit and push changes
git commit -a git push origin meta/config:meta/config
The following configuration options are available
enabled – boolean (true/false) When true, enables Slack integration (defaults to false). webhookurl - String The Slack webhook URL to publish to (defaults to an empty string). channel - String The Slack channel to publish to (defaults to "general"). username - String The Slack username to publish as (defaults to "gerrit"). ignore - Pattern A "dotall" enabled regular expression pattern that, when matches against a commit message, will prevent the publishing of patchset created event messages (defaults to an empty string). ignore-unchanged-patch-set - boolean (true/false) Whether a Slack notification about a new patch-set shouldn't be published when code didn't change (defaults to true). ignore-wip-patch-set - boolean (true/false) Whether any Slack notifications regarding a work-in-progress change shouldn't be published (defaults to true). ignore-private-patch-set - boolean (true/false) Whether any Slack notifications regarding a private change shouldn't be published (defaults to true). publish-on-patch-set-created - boolean (true/false) Whether a Slack notification should be published when a new patch set is created. publish-on-change-merged - boolean (true/false) Whether a Slack notification should be published when a change is merged. publish-on-comment-added - boolean (true/false) Whether a Slack notification should be published when a comment is added to a review. publish-on-reviewer-added - boolean (true/false) Whether a Slack notification should be published when a reviewer is added to a review. publish-on-wip-ready - boolean(true/false) Whether a Slack notification should be published when a work-in-progress change is marked ready (defaults to the value for publish-on-patch-set-created). publish-on-private-to-public - boolean(true/false) Whether a Slack notification should be published when a private change is changed to public (defaults to the value for publish-on-patch-set-created).
If a proxy is needed to connect externally to Slack, a proxy server may be configured via Gerrit's main configuration file. The path to this file will vary based on where Gerrit was installed. This example assumes that Gerrit was installed in /usr/local/gerrit.
Edit /usr/local/gerrit/etc/gerrit.config and add the following block.
[plugin "slack-integration"] proxy-host = <hostname or IP address of the proxy server> proxy-port = <port of the proxy server>
The following configuration options are available
proxy-host - String The host of the proxy server, e.g. my.proxy.host (defaults to null). proxy-port - int The port of the proxy server (defaults to 8080) proxy-username - String The username, if needed, to authenticate to the proxy server (defaults to null). proxy-password - String The password, if needed, for the specified username to authenticate to the proxy server, (defaults to null).