• This repository has been archived on 09/Jun/2021
  • Stars
    star
    186
  • Rank 200,064 (Top 5 %)
  • Language
    Java
  • License
    Other
  • Created about 9 years ago
  • Updated over 3 years ago

Reviews

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

Repository Details

Bitbucket Server plugin that invokes a custom URL when a pull request event is triggered.

Pull Request Notifier for Bitbucket Server Build Status

This project is sort of deprecated. See: https://community.developer.atlassian.com/t/eula-and-data-center-for-free-apps/26062


This is a Bitbucket Server plugin that can invoke custom URL:s, supporting variables, when configured events occur on pull requests in Bitbucket Server. It can notify Jenkins, Bamboo, TeamCity, HipChat and many more!

The original use case was to trigger Jenkins jobs to build and verify pull requests but it can trigger any system. The plugin can notify any system that can be notified with a URL.

Here is a screenshot of the admin GUI on global level. And here is a screenshot of the admin GUI on repository level.

Here is a blog post that includes the plugin.

Features

The Pull Request Notifier for Bitbucket Server can:

  • Invoke any URL, or set of URL:s, when a pull request event happens.
    • With variables available to add necessary parameters.
    • HTTP POST, PUT, GET and DELETE. POST and PUT also supports rendered post content.
  • Be configured to trigger on any pull request event. Including extended events:
    • RESCOPED_FROM, when source branch change
    • RESCOPED_TO, when target branch change
    • BUTTON_TRIGGER, when trigger button in pull request view is pressed
  • Can invoke CSRF protected systems, using the ${INJECTION_URL_VALUE} variable. How to to that with Jenkins is described below.
  • Be configured to only trigger if the pull request matches a filter. A filter text is constructed with any combination of the variables and then a regexp is constructed to match that text.
  • Add buttons to pull request view in Bitbucket Server. And map those buttons to URL invocations. This can be done by setting the filter string to ${BUTTON_TRIGGER_TITLE} and the filter regexp to title of button.
    • Buttons can have forms associated with them, and then submit the form data using the ${BUTTON_FORM_DATA} variable.
  • Authenticate with HTTP basic authentication.
  • Optionally allow any SSL certificate.
  • Use custom SSL key store, type and password.
  • Send custom HTTP headers
  • Can optionally use proxy to connect
  • Can let users and/or admins do configuration. Or restrict configuration to just system admins. A user will have to browse to the configuration page at http://domain/bitbucket/plugins/servlet/prnfb/admin.
  • Can enable trigger
    • If PR has, or has no, conflicts
    • Only if PR has conflicts
    • Only if PR has no conflicts
  • Nice configuration GUI.
    • Global at /bitbucket/plugins/servlet/prnfb/admin
    • Project level at /bitbucket/plugins/servlet/prnfb/admin/PROJECT_1
    • Repo level at /bitbucket/plugins/servlet/prnfb/admin/PROJECT_1/rep_1

The plugin has its own implementation to create the RESCOPED_FROM and RESCOPED_TO events. RESCOPED is transformed to RESCOPED_TO if target branch changed, RESCOPED_FROM if source branch, or both, changed.

The filter text as well as the URL support variables. These are:

Variable Description
${EVERYTHING_URL} This variable is resolved to all available variables. The name of each parameter is the name of that variable. Example: PULL_REQUEST_ID=1&PULL_REQUEST_TITLE=some%20thing...
${PULL_REQUEST_ID} Example: 1
${PULL_REQUEST_TITLE} Example: Anything
${PULL_REQUEST_DESCRIPTION} The ${EVERYTHING_URL} does not include this because it makes the URL very big. Example: Anything
${PULL_REQUEST_VERSION} Example: 1
${PULL_REQUEST_COMMENT_TEXT} Example: A comment
${PULL_REQUEST_COMMENT_ACTION} Example: ADDED, DELETED, EDITED, REPLIED
${PULL_REQUEST_COMMENT_ID} Example: 1234
${PULL_REQUEST_ACTION} Example: OPENED
${PULL_REQUEST_STATE} Example: DECLINED, MERGED, OPEN
${BUTTON_TRIGGER_TITLE} Example: Trigger Notification
${BUTTON_FORM_DATA} The form data that was submitted
${INJECTION_URL_VALUE} Value retrieved from any URL
${VARIABLE_REGEX_MATCH} The result of custom regex applied to a variable
${PULL_REQUEST_URL} Example: http://localhost:7990/projects/PROJECT_1/repos/rep_1/pull-requests/1
${PULL_REQUEST_USER_DISPLAY_NAME} Example: Some User
${PULL_REQUEST_USER_EMAIL_ADDRESS} Example: [email protected]
${PULL_REQUEST_USER_ID} Example: 1
${PULL_REQUEST_USER_NAME} Example: user.name
${PULL_REQUEST_USER_SLUG} Example: user.name
${PULL_REQUEST_USER_GROUPS} Example: ADMIN,DEV
${PULL_REQUEST_AUTHOR_DISPLAY_NAME} Example: Administrator
${PULL_REQUEST_AUTHOR_EMAIL} Example: [email protected]
${PULL_REQUEST_AUTHOR_ID} Example: 1
${PULL_REQUEST_AUTHOR_NAME} Example: admin
${PULL_REQUEST_AUTHOR_SLUG} Example: admin
${PULL_REQUEST_REVIEWERS} Example: Administrator,User
${PULL_REQUEST_REVIEWERS_ID} Example: 1,2
${PULL_REQUEST_REVIEWERS_SLUG} Example: admin,user
${PULL_REQUEST_REVIEWERS_EMAIL} Example: [email protected],[email protected]
${PULL_REQUEST_REVIEWERS_APPROVED_COUNT} Number of reviewers that approved the PR.
${PULL_REQUEST_REVIEWERS_APPROVED_SLUG} Example: admin,user.
${PULL_REQUEST_REVIEWERS_APPROVED_EMAIL} Example: [email protected],[email protected].
${PULL_REQUEST_REVIEWERS_APPROVED_NAME} Example: Admin,User.
${PULL_REQUEST_REVIEWERS_APPROVED_DISPLAY_NAME} Example: Admin Adminson,User Userson.
${PULL_REQUEST_REVIEWERS_UNAPPROVED_COUNT} Number of reviewers that unapproved the PR.
${PULL_REQUEST_REVIEWERS_UNAPPROVED_SLUG} Example: admin,user.
${PULL_REQUEST_REVIEWERS_UNAPPROVED_EMAIL} Example: [email protected],[email protected].
${PULL_REQUEST_REVIEWERS_UNAPPROVED_NAME} Example: Admin,User.
${PULL_REQUEST_REVIEWERS_UNAPPROVED_DISPLAY_NAME} Example: Admin Adminson,User Userson.
${PULL_REQUEST_REVIEWERS_NEEDS_WORK_COUNT} Number of reviewers that says the PR needs work.
${PULL_REQUEST_REVIEWERS_NEEDS_WORK_SLUG} Example: admin,user.
${PULL_REQUEST_REVIEWERS_NEEDS_WORK_EMAIL} Example: [email protected],[email protected].
${PULL_REQUEST_REVIEWERS_NEEDS_WORK_NAME} Example: Admin,User.
${PULL_REQUEST_REVIEWERS_NEEDS_WORK_DISPLAY_NAME} Example: Admin Adminson,User Userson.
${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT} Number of participants that approved the PR.
${PULL_REQUEST_PARTICIPANTS_EMAIL} Example: [email protected],[email protected]
${PULL_REQUEST_MERGE_COMMIT} Hash of merged commit (only available for merged-event).
${PULL_REQUEST_FROM_SSH_CLONE_URL} Example: ssh://git@localhost:7999/project_1/rep_1
${PULL_REQUEST_FROM_HTTP_CLONE_URL} Example: http://localhost:7990/bitbucket/scm/project_1/rep_1.git
${PULL_REQUEST_FROM_HASH} Example: 6053a1eaa1c009dd11092d09a72f3c41af1b59ad
${PULL_REQUEST_PREVIOUS_FROM_HASH} Example: 6053a1eaa1c009dd11092d09a72f3c41af1b59ad
${PULL_REQUEST_FROM_ID} Example: refs/heads/branchmodmerge
${PULL_REQUEST_FROM_BRANCH} Example: branchmodmerge
${PULL_REQUEST_FROM_REPO_ID} Example: 1
${PULL_REQUEST_FROM_REPO_NAME} Example: rep_1
${PULL_REQUEST_FROM_REPO_PROJECT_ID} Example: 1
${PULL_REQUEST_FROM_REPO_PROJECT_KEY} Example: PROJECT_1
${PULL_REQUEST_FROM_REPO_SLUG} Example: rep_1
${PULL_REQUEST_TO_SSH_CLONE_URL} Example: ssh://git@localhost:7999/project_1/rep_1
${PULL_REQUEST_TO_HTTP_CLONE_URL} Example: http://localhost:7990/bitbucket/scm/project_1/rep_1.git
${PULL_REQUEST_TO_HASH} Example: 6053a1eaa1c009dd11092d09a72f3c41af1b59ad
${PULL_REQUEST_PREVIOUS_TO_HASH} Example: 6053a1eaa1c009dd11092d09a72f3c41af1b59ad
${PULL_REQUEST_TO_ID} Example: refs/heads/branchmodmerge
${PULL_REQUEST_TO_BRANCH} Example: branchmodmerge
${PULL_REQUEST_TO_REPO_ID} Example: 1
${PULL_REQUEST_TO_REPO_NAME} Example: rep_1
${PULL_REQUEST_TO_REPO_PROJECT_ID} Example: 1
${PULL_REQUEST_TO_REPO_PROJECT_KEY} Example: PROJECT_1
${PULL_REQUEST_TO_REPO_SLUG} Example: rep_1

The ${PULL_REQUEST_USER...} contains information about the user who issued the event. Who commented it, who rejected it, who approved it...

You may want to use these Jenkins plugins if you are notifying Jenkins:

Integration guides

Generally, when fiddling with this plugin, you may want to use something like RequestBin. Let the notification URL point to it and you can inspect what the invoked URL looks like.

Here are some guides on how to use the plugin with different systems. Feel free to add guides through pull requests to this repo!

Button Forms

For each button you can specify a form that will show up when the button is pressed. That form data will then be submitted and will be available in the ${BUTTON_FORM_DATA} variable. Additionally, the form itself can reference other variables (with the exception of the ${BUTTON_...} ones) and will have those resolved prior to rendering.

A form is defined as a JSON array. Here is an example that shows all possibilities:

[
        {   "name": "var1",
            "label": "var1 label",
            "defaultValue": "you can put a variable like this: ${PULL_REQUEST_AUTHOR_NAME}",
            "type": "input", 
            "required": false,
            "description": "var1 description"
        },
        {   "name": "var2",
            "label": "var2 label",
            "defaultValue": "any string can go here",
            "type": "textarea", 
            "required": false,
            "description": "var2 description"
        },
        {   "name": "var3",
            "label": "var3 label",
            "defaultValue": "option2_name",
            "buttonFormElementOptionList": [
                {"label": "option1 label", "name": "option1_name"},
                {"label": "option2 label", "name": "option2_name"},
                {"label": "option3 label", "name": "option3_name"}
            ],
            "type": "radio", 
            "required": true,
            "description": "var3 description"
        },
        {   "name": "var4",
            "label": "var4 label",
            "type": "checkbox", 
            "required": true,
            "buttonFormElementOptionList": [
                {"label": "option1 label", "name": "option1_name", "defaultValue": true}, 
                {"label": "option2 label", "name": "option2_name", "defaultValue": true}
            ],
            "description": "var4 description"
        }
]

You can see a screenshot here when rendered.

When submitted with the default values, it will look like this:

{
   "var1":"you can put a variable like this: admin",
   "var2":"any string can go here",
   "var3":"option2_name",
   "var4":[
      "option1_name",
      "option2_name"
   ]
}

REST API

Some rest resources are available. You can figure out the JSON structure by looking at the DTO:s.

  • /bitbucket/rest/prnfb-admin/1.0/settings

    • GET Get all global settings.
    • POST Store all global settings.
  • /bitbucket/rest/prnfb-admin/1.0/settings/notifications

    • DELETE /{uuid} Deletes notification with uuid.
    • GET Get all notifications.
    • GET /{uuid} Get notification with uuid.
    • GET /projectKey/{projectKey} Get all notifications for the project.
    • GET /projectKey/{projectKey}/repositorySlug/{repositorySlug} Get all notifications for the project and repository.
    • POST Save a notification.
  • /bitbucket/rest/prnfb-admin/1.0/settings/buttons

    • DELETE /{uuid} Deletes button with uuid.
    • GET Get all buttons that the current user is allowed to use.
    • GET /{uuid} Get button with uuid.
    • GET /repository/{repositoryId}/pullrequest/{pullRequestId} Get all buttons for repository that the current user is allowed to use.
    • GET /projectKey/{projectKey} Get all buttons for the project.
    • GET /projectKey/{projectKey}/repositorySlug/{repositorySlug} Get all buttons for the project and repository.
    • POST Save a button.
    • POST {uuid}/press/repository/{repositoryId}/pullrequest/{pullRequestId} Press the button.

A new notification to trigger on COMMENTED can be added like this.

curl -u admin:admin 'http://localhost:7990/bitbucket/rest/prnfb-admin/1.0/settings/notifications' -H 'Content-Type: application/json; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' --data-binary '{"uuid":"","name":"","projectKey":"","repositorySlug":"","filterString":"","filterRegexp":"","triggers":["COMMENTED"],"injectionUrl":"","injectionUrlRegexp":"","user":"","password":"","proxyUser":"","proxyPassword":"","proxyServer":"","proxyPort":"","url":"http://localhost:80/?abc","method":"GET","postContent":"","headers":[{"name":"","value":""}]}'

It will respond with something like this.

{"headers":[],"method":"GET","name":"Notification","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["COMMENTED"],"url":"http://localhost:80/?abc","uuid":"b1306a3a-5a87-4145-80b7-660bc986dd25"}

It can then be changed to trigger on RESCOPED_FROM and RESCOPED_TO like this.

curl -u admin:admin 'http://localhost:7990/bitbucket/rest/prnfb-admin/1.0/settings/notifications' -H 'Content-Type: application/json; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' --data-binary '{"uuid":"b1306a3a-5a87-4145-80b7-660bc986dd25","name":"Notification","projectKey":"","repositorySlug":"","filterString":"","filterRegexp":"","triggerIfCanMerge":"ALWAYS","triggers":["RESCOPED_FROM","RESCOPED_TO"],"injectionUrl":"","injectionUrlRegexp":"","user":"","password":"","proxyUser":"","proxyPassword":"","proxyServer":"","proxyPort":"","url":"http://localhost:80/?abc","method":"GET","postContent":"","headers":[{"name":"","value":""}]}' --compressed

It will respond with something like this.

{"headers":[],"method":"GET","name":"Notification","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["RESCOPED_FROM","RESCOPED_TO"],"url":"http://localhost:80/?abc","uuid":"b1306a3a-5a87-4145-80b7-660bc986dd25"}

You may use Chrome and Developer Tools (press F12) to view rest calls while editing in GUI to find more examples.

More Repositories

1

git-changelog-lib

Generate changelog, and/or next version, with, or without, conventional commits from a GIT repository
Java
187
star
2

starta-eget-konsultbolag

Beskriver hur man startar och driver eget konsultbolag, aktiebolag.
150
star
3

violations-lib

Java library for parsing report files from static code analysis.
Java
138
star
4

jenkins-configuration-as-code-sandbox

Jenkins Configuration as Code, JCasC, Job DSL, Pipeline, Shared library
Groovy
100
star
5

git-changelog-maven-plugin

Maven plugin that can generate a changelog, or releasenotes, from git repository
Java
74
star
6

git-changelog-gradle-plugin

Automate changelog and versioning with conventional commits and Git.
Java
74
star
7

RaspberrySurveillance

Surveillance system designed for Raspberry PI
PHP
51
star
8

git-changelog-command-line

Command line tool to generate changelog, or releasenotes, from a git repository and a Handlebars template.
Java
42
star
9

violation-comments-to-github-gradle-plugin

A plugin for Gradle that will find report files from static code analysis and comment pull requests in GItHub with them.
Java
28
star
10

simple-bitbucket-commit-checker

Simple, and easy to use, commit checker for Atlassian Bitbucket Server
Java
21
star
11

violation-comments-to-github-lib

A library for commenting GitHub with violations from static code analyzer reports.
Java
20
star
12

yet-another-kotlin-vs-java-comparison

Shows complete examples where the Kotlin code is compiled to bytecode and decompiled to Java
Java
18
star
13

violations-gradle-plugin

Gradle plugin that will find report files from static code analysis, present and optionally fail the build.
Java
17
star
14

gradle-scripts

Releasing to Maven Central, Changelog generation, version management with conventional commits... a highly configurable shared Gradle script.
JavaScript
13
star
15

git-changelog-bitbucket-plugin

Atlassian Bitbucket plugin for generating changelog, or releasenotes
Java
12
star
16

bjurrcom

Ghost blog running on GitHub pages.
SCSS
11
star
17

violation-comments-lib

Library for commenting things with violations from static code analysis.
Java
11
star
18

violation-comments-to-bitbucket-cloud-command-line

Report static code analysis to Bitbucket Cloud
Java
10
star
19

violations-command-line

Command line tool that will find report files from static code analysis, present and optionally fail the command.
Java
10
star
20

violation-comments-to-gitlab-gradle-plugin

A plugin for Gradle that will find report files from static code analysis and comment merge requests in GItLab with them. Edit Add topics
Java
9
star
21

violation-comments-to-gitlab-command-line

Report static code analysis to GitLab
Java
8
star
22

bitbucket-server-jenkins-release-tags

Demo of using Bitbucket Server with Jenkins to perform releases by pushing tags to Git.
Shell
8
star
23

java-method-invocation-builder

Enables default values of method parameters in Java and is making the invocations readable.
Java
7
star
24

settings-synchronizer-for-bitbucket-plugin

Synchronize repository settings in Atlassian Bitbucket Server
Java
7
star
25

violation-comments-to-bitbucket-server-command-line

Report static code analysis to Bitbucket Server
Java
6
star
26

violation-comments-to-bitbucket-server-lib

A library for commenting Bitbucket Server with violations from static code analyzer reports.
Java
5
star
27

wiremock-jaxrs

Automates configuration of Wiremock stubs from JAX-RS annotated resources.
Java
4
star
28

violation-comments-action

A GitHub action to help use violation-comments-to-github-command-line.
4
star
29

violation-comments-to-gitlab-lib

Comment gitlab with violations found with static code analysis.
Java
4
star
30

violation-comments-to-gitlab-maven-plugin

A plugin for Maven that will find report files from static code analysis and comment merge requests in GItLab with them. Edit Add topics Edit Add topics
Java
4
star
31

violation-comments-to-github-maven-plugin

A plugin for Maven that will find report files from static code analysis and comment pull requests in GItHub with them.
Java
3
star
32

dictator-builder

Let it dictate the filesystem. Avoid code duplication in template, or boilerplate, projects.
TypeScript
3
star
33

violation-comments-to-github-command-line

Report static code analysis to GitHub
Java
3
star
34

violations-maven-plugin

Maven plugin that will find report files from static code analysis, present and optionally fail the build.
Java
3
star
35

pom-dependency-analyzer

Analyzes the output of mvn dependency:tree -DoutputType=dot -Doutput=file.dot -f pom.xml
Java
3
star
36

pom-dependency-analyzer-web

Browsable webpage, and API, with dependents, and dependencies, of Maven artifacts
Shell
3
star
37

npm-java-runner

Package JAR-files within runnable NPM packages
JavaScript
2
star
38

generate-codeowners

Generate a CODEOWNERS-file based on Git history.
TypeScript
2
star
39

HTMLUnitGenerator

Enables user friendly and powerful front end testing of web applications with minimum required effort to implement.
Java
2
star
40

kubernetes

The result of me fiddling with Kubernetes, ArgoCD, Tekton, Helm...
Mustache
1
star
41

java-method-invocation-builder-annotations

The annotations used by Java method Invocation Builder
Java
1
star
42

spring-rest-client

Dynamically create Spring Rest (proxy class) client from annotated interface.
Java
1
star
43

pom-downloader

Given a Maven repository, it will download all pom-files.
Java
1
star
44

bitbucket-server-utils-cli

Bitbucket Server utilities packaged as a standalone command line tool.
TypeScript
1
star
45

bjurr-bom

Some Maven stuff for my projects
1
star
46

plantuml-cli

Plantuml wrapped in an NPM package so that it can be run with 'npx plantuml-cli'.
Shell
1
star
47

.github

1
star
48

violations-git-lib

Provides utilities for matching violations to local Git repository.
Java
1
star