diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b598ac..87ed055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,75 @@ Changelog of Violation Comments to Bitbucket Server Plugin. ## Unreleased ### No issue +**Doc** + + +[6f886c350391fca](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/6f886c350391fca) Tomas Bjerre *2018-01-27 18:25:25* + +**Formatting** + + +[32a070215959c69](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/32a070215959c69) Joseph Petersen *2018-01-25 07:18:04* + +**Provide descriptors and config jelly** + + * Begin work on deprecated password + +[ac7ee1d0ac3e013](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/ac7ee1d0ac3e013) Joseph *2018-01-25 07:12:12* + +**Fix upperbound requirement due to parent POM upgrade** + + +[82c791dfac4fb09](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/82c791dfac4fb09) Joseph *2018-01-25 07:12:12* + +**One too many extension** + + +[794b26ab74ce4ef](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/794b26ab74ce4ef) Joseph *2018-01-25 07:12:12* + +**Delete button** + + +[6121212b8c5134c](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/6121212b8c5134c) Joseph *2018-01-25 07:12:12* + +**Migrate to credentials** + + +[5438932ae8da3a3](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/5438932ae8da3a3) Joseph *2018-01-25 07:12:12* + +**Update and cleanup POM** + + +[2a919e623566d04](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/2a919e623566d04) Joseph *2018-01-25 07:12:12* + +**cleanup dead code** + + +[037e30e6268e71b](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/037e30e6268e71b) Joseph *2018-01-25 07:12:12* + +**Update Jenkinsfile** + + +[d54f6eb2cfbe9aa](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/d54f6eb2cfbe9aa) Joseph Petersen *2018-01-24 21:33:31* + +**Give it a symbol and extension** + + +[811b69be0183ca2](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/811b69be0183ca2) Joseph *2018-01-24 15:31:14* + + +## 1.64 +### No issue + +**Google error-prone** + + +[187c30137e46d29](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/187c30137e46d29) Tomas Bjerre *2018-01-14 11:59:05* + + +## 1.63 +### No issue + **Relocating to correct Java identifier** diff --git a/README.md b/README.md index 7778efb..6d9fa4b 100644 --- a/README.md +++ b/README.md @@ -59,35 +59,17 @@ The pull request will be commented like this. Available in Jenkins [here](https://wiki.jenkins-ci.org/display/JENKINS/Violation+Comments+to+Bitbucket+Server+Plugin). -## Example use case -Here is an example use case where a pull request is triggered from Bitbucket Server, merged, checked and comments added to pull request in Bitbucket Server. - -You may also use it for an ordinary build job, to simply comment the commit that was built. - ### Notify Jenkins from Bitbucket Server -You can use [Generic Webhook Trigger plugin](https://github.com/tomasbjerre/generic-webhook-trigger-plugin) to get the variables you need. -You may also use [Pull Request Notifier for Bitbucket Server](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket) to trigger a Jenkins build from an event in Bitbucket Server. 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} -``` +* You may trigger with a [webhook](https://confluence.atlassian.com/bitbucketserver/managing-webhooks-in-bitbucket-server-938025878.html) in Bitbucket Server. And consume it with [Generic Webhook Trigger plugin](https://github.com/tomasbjerre/generic-webhook-trigger-plugin) to get the variables you need. -### 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 +* Or, trigger with [Pull Request Notifier for Bitbucket Server](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket). 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}` -The shell script may look like this. +*You must perform the merge before build*. If you don't perform the merge, the reported violations will refer to other lines then those in the pull request. The merge can be done with a shell script like this. ``` echo --- -echo --- Mergar from $FROM in $FROMREPO to $TO in $TOREPO +echo --- Merging from $FROM in $FROMREPO to $TO in $TOREPO echo --- git clone $TOREPO cd * @@ -98,15 +80,9 @@ git fetch from git merge $FROM git --no-pager log --max-count=10 --graph --abbrev-commit -your build command here! +Your build command here! ``` -### Configure plugin -This plugin may be added as a post build step to analyze the workspace and report comments back to pull request in Bitbucket Server. [Here](https://raw.githubusercontent.com/tomasbjerre/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/violation-comments-to-stash-plugin/master/sandbox/screenshot-stash.png) is an example Bitbucket Server comment. - ## Job DSL Plugin This plugin can be used with the Job DSL Plugin. Here is an example. @@ -204,12 +180,7 @@ git --no-pager log --max-count=10 --graph --abbrev-commit repoSlug("\$PULL_REQUEST_TO_REPO_SLUG") pullRequestId("\$PULL_REQUEST_ID") - useUsernamePasswordCredentials(false) - usernamePasswordCredentialsId(null) - - useUsernamePassword(true) - username("admin") - password("admin") + usernamePasswordCredentialsId('bitbucketservercredentials') minSeverity('INFO') createSingleFileComments(true) @@ -242,40 +213,38 @@ This plugin can be used with the Pipeline Plugin: ``` node { - def mvnHome = tool 'Maven 3.3.9' deleteDir() stage('Merge') { - sh "git init" - sh "git fetch --no-tags --progress git@git:group/reponame.git +refs/heads/*:refs/remotes/origin/* --depth=200" - sh "git checkout origin/${env.targetBranch}" - sh "git merge origin/${env.sourceBranch}" - sh "git log --graph --abbrev-commit --max-count=10" + sh ''' + git clone git@github.com:tomasbjerre/violations-test.git . + git checkout master + git merge origin/feature/addingcrap + ''' + } + + stage('Build') { + sh ''' + ./build.sh || ls + ''' } stage('Static code analysis') { - sh "${mvnHome}/bin/mvn package -DskipTests -Dmaven.test.failure.ignore=false -Dsurefire.skip=true -Dmaven.compile.fork=true -Dmaven.javadoc.skip=true" - - step([ - $class: 'ViolationsToBitbucketServerRecorder', - config: [ - bitbucketServerUrl: 'http://localhost:7990/bitbucket', - createCommentWithAllSingleFileComments: false, - createSingleFileComments: true, - projectKey: 'PROJECT_1', - repoSlug: 'rep_1', - pullRequestId: '1', - useUsernamePassword: true, - username: 'admin', - password: 'admin', - useUsernamePasswordCredentials: false, - minSeverity: 'INFO', - keepOldComments: false, - violationConfigs: [ - [ pattern: '.*/checkstyle-result\\.xml$', parser: 'CHECKSTYLE', reporter: 'Checkstyle' ], - [ pattern: '.*/findbugsXml\\.xml$', parser: 'FINDBUGS', reporter: 'Findbugs' ], - [ pattern: '.*/pmd\\.xml$', parser: 'PMD', reporter: 'PMD' ], - ] + ViolationsToBitbucketServer([ + bitbucketServerUrl: 'http://localhost:7990/', + commentOnlyChangedContent: true, + commentOnlyChangedContentContext: 5, + createCommentWithAllSingleFileComments: false, + createSingleFileComments: true, + keepOldComments: true, + projectKey: 'PROJ', // Use environment variable here + pullRequestId: '1', // Use environment variable here + repoSlug: 'violations-test', // Use environment variable here + usernamePasswordCredentialsId: 'bitbucketservercredentials', //Create a Username/Passwords credential with this ID + violationConfigs: [ + // Many more formats available, check https://github.com/tomasbjerre/violations-lib + [parser: 'FINDBUGS', pattern: '.*/findbugs/.*\\.xml\$', reporter: 'Findbugs'], + [parser: 'CHECKSTYLE', pattern: '.*/checkstyle/.*\\.xml\$', reporter: 'Checkstyle'] ] ]) } @@ -285,12 +254,6 @@ node { ## Developer instructions Instructions for developers. -### Get the code - -``` -git clone git@github.com:tomasbjerre/violation-comments-to-stash-plugin.git -``` - ### Plugin development More details on Jenkins plugin development is available [here](https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial). diff --git a/debug.sh b/debug.sh index e29ef8e..c0150ee 100755 --- a/debug.sh +++ b/debug.sh @@ -1,3 +1,3 @@ #!/bin/sh -mvnDebug -q hpi:run -Djava.util.logging.config.file=logging.properties +mvnDebug -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.89.3 diff --git a/run.sh b/run.sh index dec7966..569530d 100755 --- a/run.sh +++ b/run.sh @@ -1,2 +1,2 @@ #!/bin/sh -mvn -q hpi:run -Djava.util.logging.config.file=logging.properties +mvn -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.89.3 diff --git a/sandbox/violations-test.jenkinsfile b/sandbox/violations-test.jenkinsfile index 26cb49e..b06f6d2 100644 --- a/sandbox/violations-test.jenkinsfile +++ b/sandbox/violations-test.jenkinsfile @@ -23,11 +23,8 @@ node { createSingleFileComments: true, projectKey: 'PROJ', repoSlug: 'violations-test', + usernamePasswordCredentialsId: 'bitbucketservercredentials' pullRequestId: '1', - useUsernamePassword: true, - username: 'admin', - password: 'admin', - useUsernamePasswordCredentials: false, minSeverity: 'INFO', keepOldComments: false, violationConfigs: [