-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
812f801
commit deaa65b
Showing
49 changed files
with
2,360 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
target | ||
.project | ||
.settings | ||
.classpath | ||
*.class | ||
*.log | ||
*.bak | ||
*~ | ||
work | ||
bin | ||
gradle | ||
gradlew | ||
.gradle | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "plugin/violations-plugin"] | ||
path = plugin/violations-plugin | ||
url = git://github.com/jenkinsci/violations-plugin.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: java | ||
jdk: | ||
- oraclejdk8 | ||
- oraclejdk7 | ||
- openjdk6 | ||
script: | ||
- ./build.sh | ||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Jenkins Violation Comments to Stash Plugin | ||
|
||
Changelog of Jenkins Violation Comments to Stash Plugin | ||
|
||
## 1.0 | ||
* Initial Release | ||
* Alot of use cases are untested and any user should expect to find issues. But since I do not have time for testing everything, I'll release 1.0 "as is"! Please report any issues you find =) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2014 Sean Ford | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,86 @@ | ||
# jenkins-violation-comments-to-stash-plugin | ||
Analyzes Jenkins workspace to find code analyzer report files, comments Stash pull requests with code analyzer comments. | ||
# Jenkins Violation Comments to Stash [![Build Status](https://travis-ci.org/tomasbjerre/jenkins-violation-comments-to-stash-plugin.svg?branch=master)](https://travis-ci.org/tomasbjerre/jenkins-violation-comments-to-stash-plugin) | ||
This is much like the [Violations](https://wiki.jenkins-ci.org/display/JENKINS/Violations) plugin. Instead of publishing violation reports in Jenkins, it comments pull requests in Stash. | ||
|
||
Code from the [Violations](https://wiki.jenkins-ci.org/display/JENKINS/Violations) is used through a submodule. | ||
|
||
There is a screenshot of the configuration GUI [here](https://raw.githubusercontent.com/tomasbjerre/jenkins-violation-comments-to-stash-plugin/master/sandbox/screenshot-config.png). | ||
|
||
#Features | ||
* Comment pull requests with code analyzers comments | ||
* Supporting: CheckStyle, CSSLint, JSLint, CodeNarc, CPPLint, FindBugs, FxCop, Gendarme, JCEReport, PEP8, PerlCritic, PMD, PyLint, Simian, StyleCop | ||
|
||
## Use case | ||
Here is an example use case where a pull request is triggered from Stash, merged, checked and comments added to pull request in Stash. | ||
|
||
### Notify Jenkins from Stash | ||
You may use [Pull Request Notifier for Stash](https://github.com/tomasbjerre/pull-request-notifier-for-stash) to trigger a Jenkins build from an event in Stash. It can supply any parameters and variables you may need. Here is an example URL. | ||
|
||
``` | ||
http://localhost:8080/jenkins/job/builder/buildWithParameters?FROM=${PULL_REQUEST_FROM_HASH}&TO=${PULL_REQUEST_TO_HASH}&TOSLUG=${PULL_REQUEST_TO_REPO_SLUG}&TOREPO=${PULL_REQUEST_TO_HTTP_CLONE_URL}&FROMREPO=${PULL_REQUEST_FROM_HTTP_CLONE_URL}&ID=${PULL_REQUEST_ID}&PROJECT=${PULL_REQUEST_TO_REPO_PROJECT_KEY} | ||
``` | ||
|
||
### Jenkins job | ||
The Jenkins job may perform the merge, and run any checkers on it, with a shell script build step. It needs to be a parameterized build. To match URL in example above, these parameters are needed. | ||
* ID | ||
* TO | ||
* TOSLUG | ||
* TOREPO | ||
* FROM | ||
* FROMREPO | ||
* PROJECT | ||
|
||
The shell script may look like this. | ||
|
||
``` | ||
echo --- | ||
echo --- Mergar from $FROM in $FROMREPO to $TO in $TOREPO | ||
echo --- | ||
git clone $TOREPO | ||
cd * | ||
git reset --hard $TO | ||
git status | ||
git remote add from $FROMREPO | ||
git fetch from | ||
git merge $FROM | ||
git --no-pager log --max-count=10 --graph --abbrev-commit | ||
your build command here! | ||
``` | ||
|
||
### Configure plugin | ||
This plugin may be added as a post build step to analyse the workspace and report comments back to pull request in Stash. [Here](https://raw.githubusercontent.com/tomasbjerre/jenkins-violation-comments-to-stash-plugin/master/sandbox/screenshot-config.png) is an example of how that may look like. | ||
|
||
### The result | ||
And finally [here](https://raw.githubusercontent.com/tomasbjerre/jenkins-violation-comments-to-stash-plugin/master/sandbox/screenshot-stash.png) is an example stash comment. | ||
|
||
## Developer instructions | ||
Instructions for developers. | ||
|
||
### Get the code | ||
|
||
Clone repo, including submodules. | ||
|
||
``` | ||
git clone --recursive [email protected]:tomasbjerre/jenkins-violation-comments-to-stash-plugin.git | ||
``` | ||
|
||
Or if you already cloned the repo. | ||
|
||
``` | ||
git submodule update --init --recursive | ||
``` | ||
|
||
### Plugin development | ||
More details on Jenkins plugin development is available [here](https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial). | ||
|
||
There is a ```/build.sh``` that will perform a full build and test the plugin. | ||
|
||
Some tests are implemented in maven project in ```/plugin-test```. This is to avoid classpath issues with the plugin. These are web tests that will start Jenkins with the plugin on localhost and perform some configuration tests. | ||
|
||
The actual plugin is implemented in ```/plugin```. | ||
|
||
A release is created like this, in ```plugin```. | ||
``` | ||
mvn release:prepare | ||
mvn release:perform | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
function build_clean { | ||
for KILLPID in `ps ax | grep 'hpi:run' | awk ' { print $1;}'`; do | ||
echo "Jenkins is running at $KILLPID, killing it" | ||
kill $KILLPID || echo; | ||
done | ||
} | ||
|
||
## | ||
## Setup | ||
## | ||
echo Setting up Maven | ||
mkdir -p ~/.m2 | ||
cp sandbox/settings.xml ~/.m2/settings.xml | ||
|
||
## | ||
## Build plugin | ||
## | ||
echo Building plugin | ||
cd plugin | ||
mvn -q package || exit 1 | ||
|
||
## | ||
## Start Jenkins on localhost | ||
## | ||
echo Starting Jenkins on localhost | ||
build_clean | ||
JENKINS_PORT=8123 | ||
JENKINS_PREFIX=/jenkins | ||
mvn -q hpi:run -Djetty.port=$JENKINS_PORT -Dhpi.prefix=$JENKINS_PREFIX || exit 1 & | ||
JENKINS_URL=http://localhost:$JENKINS_PORT$JENKINS_PREFIX | ||
until $(curl --output /dev/null --silent --head --fail $JENKINS_URL); do | ||
printf '.' | ||
sleep 5 | ||
done | ||
echo Jenkins started at $JENKINS_URL | ||
|
||
## | ||
## Test plugin | ||
## | ||
cd .. | ||
cd plugin-test | ||
mvn -q test -Djenkins=$JENKINS_URL -Dheadless=true || exit 1 | ||
cd .. | ||
|
||
## | ||
## Exit | ||
## | ||
build_clean | ||
|
||
sleep 5 | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
rm -rf target | ||
rm -rf work | ||
|
||
cd plugin | ||
rm -rf target | ||
rm -rf work | ||
mvn -q clean | ||
cd .. | ||
|
||
cd plugin/violations-plugin | ||
mvn -q clean | ||
cd ../.. | ||
|
||
cd plugin-test | ||
mvn -q clean | ||
cd .. | ||
|
||
find -name *.class | xargs rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
cd plugin | ||
mvnDebug -q hpi:run | ||
|
Oops, something went wrong.