• Stars
    star
    201
  • Rank 194,491 (Top 4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Static code review for your Gerrit patchsets. Runs Checkstyle, PMD, FindBugs, Scalastyle, CodeNarc, JSLint for you!

sputnik

Static code review for your Gerrit and Stash patchsets. Runs Checkstyle, PMD, SpotBugs (formerly known as FindBugs), Scalastyle, CodeNarc, JSLint, JSHint, TSLint and Detekt for you!

Build Status Maven Central Coverage Status Sputnik Join the chat at https://gitter.im/TouK/sputnik

Usage

Sputnik runs Checkstyle, PMD, SpotBugs, CodeNarc, JSHint (or JSLint), TSLint, Ktlint and Detekt only on files affected by Gerrit's patchset. It collects all violations and report them back to Gerrit or Stash.

Typical configuration file looks like this:

connector.type=gerrit
connector.host=your.host.com
connector.path=/gerrit
connector.port=8080
connector.username=sputnik
connector.password=PassWd
connector.useHttps=false
connector.verifySsl=false
connector.tag=sputnik
checkstyle.enabled=true
checkstyle.configurationFile=sun_checks.xml
checkstyle.propertiesFile=
pmd.enabled=true
pmd.ruleSets=rulesets/java/android.xml,rulesets/java/basic.xml
spotbugs.enabled=true
spotbugs.includeFilter=
spotbugs.excludeFilter=
codenarc.enabled=true
codenarc.ruleSets=
codenarc.excludes=**/*.java
jslint.enabled=false
jshint.enabled=true
jshint.configurationFile=jshint.json
tslint.enabled=true
tslint.script=/usr/bin/tslint
tslint.configurationFile=tslint.json
ktlint.enabled=true
ktlint.exclude=no-semi,indent
detekt.enabled=true
detekt.config.file=src/test/resources/detekt/config/config.yml

See this for a downloadable sample file, and this for a full list of options.

If you want sputnik to use your SonarQube rules just download them from your SonarQube profile and use these with checkstyle.configurationFile, pmd.ruleSets and spotbugs.includeFilter variables.

To ease migration from FindBugs to SpotBugs these three configuration properties still work and affect SpotBugs now: findbugs.enabled, findbugs.includeFilter and findbugs.excludeFilter.

Installation

  • clone this repository and build it: gradle distZip or download distribution
  • copy distribution file build/distributions/sputnik-2.6.0.zip to your installation dir, e.g. /opt/sputnik and unzip it
  • to avoid problems with deployment keep the structure unchanged, so sputnik file is in bin/ directory, jars in lib/
  • create configuration file (you can just paste and edit an example above), e.g. /opt/sputnik/myconf.properties
  • you can now run sputnik like this:
/opt/sputnik/bin/sputnik --conf /opt/sputnik/gerrit.properties --changeId I0a2afb7ae4a94ab1ab473ba00e2ec7de381799a0 --revisionId 3f37692af2290e8e3fd16d2f43701c24346197f0

Build tool

Sputnik is intended to run just after your Jenkins/CI server build. It should be executed in the root directory of the analyzed project to find files to analyze.

Sputnik currently supports Maven (default) and Gradle. Some processors (e.g. SpotBugs) analyze compiled classes, so it's important to set the build tool property correctly. To change it to Gradle just set project.build.tool=gradle in your sputnik.properties file.

Gerrit support

Three parameters are required: your configuration file (details below), Gerrit's changeId and revisionId. ie:

sputnik --conf /path/to/conf.properties --changeId I0a2afb7ae4a94ab1ab473ba00e2ec7de381799a0 --revisionId 3f37692af2290e8e3fd16d2f43701c24346197f0

Other parameters are available. See them with sputnik --help.

Depending on your workflow it can happen that the changeId matches changes on multiple branches, for example when you push a change set identified by particular changeId into your working branch and review branch.
You can recognize it by the following error message:

Request not successful. Message: Not Found. Status-Code: 404. Content: Not found: yours_change_id

In this case the extended changeId format (REPO_NAME~BRANCH_NAME~CHANGE_ID) should be used which includes the repository and the branch name, for example:

sputnik --conf /path/to/conf.properties --changeId myProject~master~I0a2afb7ae4a94ab1ab473ba00e2ec7de381799a0 --revisionId 3f37692af2290e8e3fd16d2f43701c24346197f0

Stash support

If you choose to run sputnik with Stash instead of Gerrit, you'll need to run it in the following manner:

/opt/sputnik/bin/sputnik --conf /opt/sputnik/stash.properties --pullRequestId 15

It is convenient to add sputnik's configuration file (myconf.properties in the above example) to your project's repo. This way, it will be easier to run it from CI server.

SSL verification

SSL trust verification and hostname verification is disabled by default. You can enable it by setting connector.verifySsl=true property.

Add Post-Build step to Jenkins/CI server

If you have Jenkins job that uses Gerrit Trigger plugin it's very easy to integrate it as Post-Build step:

/opt/sputnik/bin/sputnik --conf /opt/sputnik/myconf.properties --changeId $GERRIT_CHANGE_ID --revisionId $GERRIT_PATCHSET_REVISION
# This line makes sure that this Post-Build step always returns exit code 0
# so it won't affect your main build result
echo "exit 0 workaround"

Add Post-Build step to Bamboo

When stash is build on Bamboo there is no direct way to check which pull request id it matches. This is a simple way to find required id.

Assumptions:

  • there is sputnik's config file named sputnik.properties in project's root directory
  • user and password are configured in bamboo plan as variables (e.g. ecosystem.username and ecosystem.password)
  • config file has placeholders for user and password:
stash.username=<username>
stash.password=<password>

With those steps in place you can use a step from contrib/stash-execute.sh:

current_branch=${bamboo.repository.branch.name} sputnik_distribution_url=https://github.com/TouK/sputnik/releases/download/sputnik-1.4.0/sputnik-1.4.0.zip stash_password=${bamboo_ecosystem_password} stash_user=${bamboo_ecosystem_username} ./stash-execute.sh

Launching with Maven

If you prefer running Sputnik from Maven, there is a plugin developed by Karol Lassak here: https://github.com/ingwarsw/sputnik-maven-plugin. Read plugin documentation for reference.

Launching with Gradle

If you prefer running Sputnik from Gradle all you need is to have Gradle installed. Put build.gradle file in your repository, add config file and run:

gradle run -Dexec.args="--conf example.properties --changeId 1234 --revisionId 4321"

Requirements

  • Gerrit 2.8 is required (REST API for reviews was introduced in this version)
  • Jenkins or other CI server to download and build patchsets

Contributors

  • Tomasz Kalkosiล„ski
  • Marcin Cylke
  • Piotr Jagielski
  • Karol Lassak
  • Henning Hoefer
  • Dominik Przybysz
  • Damian Szczepanik
  • Rafaล‚ Nowak
  • Filip Majewski

License

This project is licenced under Apache License.

More Repositories

1

nussknacker

Low-code tool for automating actions on real time data | Stream processing for the users.
Scala
652
star
2

krush

Idiomatic persistence layer forย Kotlin
Kotlin
248
star
3

bubble

Screen orientation detector for android
Kotlin
99
star
4

excel-export

excel-export grails plugin
Groovy
58
star
5

kotlin-exposed-realworld

Medium clone backend using Kotlin, Spring, Krush and Exposed. API as specified on https://realworld.io/
Kotlin
48
star
6

plumber

plumber helps you tame NiFi flow
Scala
44
star
7

sputnik-ci

Sputnik.ci - Continuous code reviews
Python
16
star
8

dockds

Docker contained database autoconfiguration for Spring Boot
Java
11
star
9

janusz

Slack bot for simplifying developer life
Java
10
star
10

http-mock-server

Groovy
9
star
11

nussknacker-kubernetes

Example deployment setup for running Nussknacker with Flink on Kubernetes cluster.
Shell
8
star
12

nussknacker-quickstart

Docker Demo for Nussknacker - A visual tool to define and run real-time decision algorithms. Brings agility to business teams, liberates developers to focus on technology.
Shell
8
star
13

ctrl-pkw

Informacje na temat akcji "policzymy gล‚osy w wyborach prezydenckich" i aplikacji dostฤ™pne na stronie
Java
8
star
14

nussknacker-helm

Helm chart installing Nussknacker
Shell
7
star
15

re-cms

A simple embeddable CMS
Clojure
6
star
16

akka-http-swagger

An attempt to automatically generate and serve swagger documentation for REST APIs built with akka-http
JavaScript
5
star
17

hades

High Availability Data Source
Java
5
star
18

touk-bash

Bash snippets for your development
Shell
5
star
19

influxdb-reporter

Reporter to Influxdb 0.9 implementing (extended) Dropwizard metrics API
Scala
5
star
20

excel-export-samples

Examples on how to use excel-export plugin
Groovy
5
star
21

camel-spock

Small library allowing you to test your Camel routes with Spock
Groovy
5
star
22

airboat

A no-ceremony code review app, firstly developed during summer internships (2012) at TouK
JavaScript
4
star
23

RapidOSS3TouK

TouK Open Source fork to RapidOSS v3. RapidOSS is delivered by iFountain (http://www.ifountain.com) and you should go for stabe/official builds there. This here is to allow us to share any work we can, so it can be merged back to officiall build if it's worth it.
Groovy
4
star
24

jedzieTramwaj

Scala
3
star
25

QuaK

2D liero/soldat-inspired game made in 2 MD during internal TouK hackaton
Kotlin
3
star
26

jpub-maven-plugin

Maven3 plugin that integrates Oracle JPublisher into Maven project lifecycle
Groovy
3
star
27

nussknacker-flink-compatibility

Additional code needed for using Nussknacker with different Flink versions
Scala
3
star
28

petasos

A better user interface for https://github.com/allegro/hermes
TypeScript
3
star
29

confitura-man

A simple JS game created during 1-day hackathon.
JavaScript
3
star
30

cxf-utils

Java
2
star
31

jedzie-tramwaj-web

CoffeeScript
2
star
32

duck404

JavaScript
2
star
33

krush-example

Example project using krush
Kotlin
2
star
34

ormtest

Framework for unit testing Spring based DAOs
Java
2
star
35

angular-typewriter

Typewriter angular directive
JavaScript
2
star
36

angular-workshop

Source code from workshop about AngularJS @ TouK
JavaScript
2
star
37

gxt-tools

Java
2
star
38

widerest

RESTful API for Broadleaf Commerce
Java
2
star
39

touk-framework

Java
2
star
40

sonar-file-alerts-plugin

This plugin raises alerts on file level in Sonar. It extends default behaviour, which raises alerts only at root project level.
Java
2
star
41

nussknacker-scenario-examples-library

Nussknacker Scenario Examples Library
Shell
1
star
42

nifi-oidc-quickstart

Example NiFi and NiFi Registry with authorization by external OpenId Connect provider
Shell
1
star
43

nussknacker-installation-example

Example, docker-based installation of Nu (https://github.com/TouK/nussknacker) and its dependencies.
Shell
1
star
44

nussknacker-firebase-example

Shell
1
star
45

nussknacker-elasticsearch-example

docker-compose example showing how to process business events stored on elasticsearch using nussknacker
Shell
1
star
46

devoxx-tv

Chromecast Hello World
JavaScript
1
star
47

gwtaculous

Java
1
star
48

touk-url

Haskell
1
star
49

nk-windows

Window manager used in Nussknacker (nussknacker.io)
TypeScript
1
star
50

ignite-issues

Java
1
star
51

nussknacker-sample-components

Sample components for Nussknacker
Scala
1
star
52

ksp-example

Kotlin Symbol Processing example
Kotlin
1
star
53

metatype-exporter-maven-plugin

Generate markdown file from OSGI metatype xml
Groovy
1
star
54

touk-angular-lib

CoffeeScript
1
star
55

nussknacker-benchmarks

Benchmarks for Nussknacker - A visual tool to define and run real-time decision algorithms. Brings agility to business teams, liberates developers to focus on technology.
Python
1
star