aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 4cff2619dfd8e39397e0494be42ad644415c9d9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
BBPRB
=====

This plugin is a revision of original [Bitbucket Pull Request Builder Plugin](https://wiki.jenkins.io/display/JENKINS/Bitbucket+pullrequest+builder+plugin).
It was started by adding support for [Bitbucket webhooks](https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html)
and resulted in massive rewrite and deleting the code. Jenkins 2.60+ is required.


Configuration
=============

Configuring Jenkins job
-----------------------

This plugin needs credentials to access Bitbucket API. The credentials comprise
the user's name and a password. This password is known as "App password" and
it is not the same as the user's password.

Only Git repositories are supported.

These environment variables are set when the job is triggered by this plugin:

```
bbprbDestinationBranch
bbprbDestinationCommitHash
bbprbDestinationRepository
bbprbPullRequestAuthor
bbprbPullRequestId
bbprbPullRequestTitle
bbprbSourceBranch
bbprbSourceCommitHash
bbprbSourceRepository
```

Recommended Git configuration:

* Repository URL: `git@bitbucket.org:${bbprbDestinationRepository}.git`
* Branch Specifier: `${bbprbSourceCommitHash}`
* [Optional] Branch to merge to: `${bbprbDestinationBranch}`

![Recommended git configuration](./screenshots/bbprb-git-config.png)


Trigger's options in Jenkins graphical user interface:

![Jenkins trigger configuration](./screenshots/bbprb-config.png)


Trigger's options in the job's XML configuration file:

```xml
  <triggers>
    <org.jenkinsci.plugins.bbprb.BitbucketBuildTrigger plugin="bbprb@0.2.0">
      <spec></spec>
      <ciKey>jenkins</ciKey>
      <ciName>Jenkins</ciName>
      <credentialsId>bitbucket-pwd</credentialsId>
      <destinationRepository>bbuser/gitrepository</destinationRepository>
      <cancelOutdatedJobs>true</cancelOutdatedJobs>
    </org.jenkinsci.plugins.bbprb.BitbucketBuildTrigger>
  </triggers>

```


Configuring Bitbucket web-hook
------------------------------

The end-point is `/bbprb-hook/`. Currently only two events are supported:
pull request is created and pull request is updated.

![Bitbucket web-hook configuration](./screenshots/bb-hook.png)


Installation
============

Use [Apache Maven](https://maven.apache.org/) to build and package the plugin:

```
$ cd bbprb
$ mvn install

```

This will create the file `./target/bbprb.hpi` that you can deploy to Jenkins.
See [Jenkins Plugin tutorial](https://wiki.jenkins.io/display/JENKINS/Plugin+tutorial) for more details.
Other useful commands are `mvn compile`, `mvn hpi:hpi`.


Copyright
=========

(C) 2017-2018 Igor Pashev <pashev.igor@gmail.com>.

(C) 2014 S.nishio + Martin Damovsky.

This plugin is free software under the [BSD License](./COPYING).