Skip to content

Commit c5cd38f

Browse files
authored
feat(api,vcs): use new vcs project (#6160)
* feat(api,vcs): use new vcs project Signed-off-by: Yvonnick Esnault <[email protected]>
1 parent dec0398 commit c5cd38f

File tree

85 files changed

+1610
-1385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1610
-1385
lines changed

docs/content/docs/integrations/bitbucket.md

+21-155
Original file line numberDiff line numberDiff line change
@@ -17,168 +17,34 @@ This integration enables some features:
1717
- Send [build notifications](https://developer.atlassian.com/server/bitbucket/how-tos/updating-build-status-for-commits/) on your Pull-Requests and Commits on Bitbucket. [More informations]({{<relref "/docs/concepts/workflow/notifications.md#vcs-notifications" >}})
1818
- [Send comments on your Pull-Requests when a workflow is failed]({{<relref "/docs/concepts/workflow/notifications.md#vcs-notifications" >}})
1919

20-
## How to configure Bitbucket Server integration
20+
### Create the Personal Access Token on Bitbucket Datacenter
2121

22-
You need to perform the following steps:
22+
Generate a new token on https://your-bitbucket-datacenter/plugins/servlet/access-tokens/manage with the following scopes:
23+
- `PROJECT READ`
24+
- `REPOSITORY READ`
2325

24-
- Bitbucket admin privileges
25-
- A RSA Key Pair
26-
27-
### Generate RSA Key Pair
28-
29-
Create the private RSA certificate:
30-
31-
```
32-
$ openssl genrsa -out key.pem 1024
33-
```
34-
35-
The content of key.pem have to be used as `privateKey` below in CDS Configuration file.
36-
37-
Generate the public RSA certificate:
38-
39-
```
40-
$ openssl rsa -in key.pem -pubout
41-
```
42-
43-
This will display the public key, you will have to copy-paste it inside `Public Key` field on Bitbucket.
44-
45-
46-
### Create a CDS application in Bitbucket
47-
In Bitbucket go to *Administration Settings* / *Application Links*. Create a new Application with:
48-
49-
- Name: **CDS**
50-
- Type: **Generic Application**
51-
- Application URL: *Your CDS API URL*
52-
- Display URL: *Your CDS API URL*
53-
54-
On this application, you just have to set up *OAuth Incoming Authentication*:
55-
56-
- Consumer Key: **CDS** (you can change it in your configuration file)
57-
- Consumer Name: **CDS**
58-
- Public Key: *Your CDS RSA public key*
59-
- Consumer Callback URL: None
60-
- Allow 2-Legged OAuth: false
61-
- Execute as: None
62-
- Allow user impersonation through 2-Legged OAuth: false
63-
64-
### Complete CDS Configuration File
65-
66-
Set value to `privateKey`. You can modify `consumerKey` if you want.
67-
68-
```yaml
69-
[vcs.servers]
70-
71-
[vcs.servers.Bitbucket]
72-
73-
# URL of this VCS Server
74-
url = "https://mybitbucket.com"
75-
76-
[vcs.servers.Bitbucket.bitbucket]
77-
78-
#######
79-
# CDS <-> Bitbucket. Documentation on https://ovh.github.io/cds/hosting/repositories-manager/bitbucket/
80-
########
81-
# You can change the consumeKey if you want
82-
consumerKey = "CDS"
83-
84-
# Does polling is supported by VCS Server
85-
disablePolling = false
86-
87-
# Does webhooks are supported by VCS Server
88-
disableWebHooks = false
89-
privateKey = "-----BEGIN PRIVATE KEY-----\n....\n-----END PRIVATE KEY-----"
90-
91-
# If you want to have a reverse proxy URL for your repository webhook, for example if you put https://myproxy.com it will generate a webhook URL like this https://myproxy.com/UUID_OF_YOUR_WEBHOOK
92-
# proxyWebhook = ""
93-
94-
# optional, Bitbucket Token associated to username, used to add comment on Pull Request
95-
token = ""
96-
97-
# optional. Bitbucket username, used to add comment on Pull Request on failed build.
98-
username = ""
99-
100-
[vcs.servers.Bitbucket.bitbucket.Status]
101-
102-
# Set to true if you don't want CDS to push statuses on the VCS server
103-
# disable = false
104-
```
105-
106-
You can configure many instances of Bitbucket:
26+
### Import configuration
10727

28+
Create a yml file:
10829

10930
```yaml
110-
111-
[vcs.servers]
112-
113-
[vcs.servers.mybitbucket_instance1]
114-
115-
# URL of this VCS Server
116-
url = "https://mybitbucket-instance1.localhost"
117-
118-
[vcs.servers.mybitbucket_instance1.bitbucket]
119-
consumerKey = "CDS_Instance1"
120-
121-
# Does polling is supported by VCS Server
122-
disablePolling = true
123-
124-
# Does webhooks are supported by VCS Server
125-
disableWebHooks = false
126-
127-
# Does webhooks creation are supported by VCS Server
128-
disableWebHooksCreation = false
129-
privateKey = "-----BEGIN PRIVATE KEY-----\n....\n-----END PRIVATE KEY-----"
130-
131-
# If you want to have a reverse proxy URL for your repository webhook, for example if you put https://myproxy.com it will generate a webhook URL like this https://myproxy.com/UUID_OF_YOUR_WEBHOOK
132-
# proxyWebhook = "https://myproxy.com"
133-
134-
[vcs.servers.mybitbucket_instance1.bitbucket.Status]
135-
136-
# Set to true if you don't want CDS to push statuses on the VCS server
137-
disable = false
138-
139-
# Set to true if you don't want CDS to push CDS URL in statuses on the VCS server
140-
showDetail = true
141-
142-
[vcs.servers.mybitbucket_instance2]
143-
144-
# URL of this VCS Server
145-
url = "https://mybitbucket-instance2.localhost"
146-
147-
[vcs.servers.mybitbucket_instance2.bitbucket]
148-
consumerKey = "CDS_Instance2"
149-
150-
# Does polling is supported by VCS Server
151-
disablePolling = true
152-
153-
# Does webhooks are supported by VCS Server
154-
disableWebHooks = false
155-
156-
# Does webhooks creation are supported by VCS Server
157-
disableWebHooksCreation = false
158-
privateKey = "-----BEGIN PRIVATE KEY-----\n....\n-----END PRIVATE KEY-----"
159-
160-
# If you want to have a reverse proxy URL for your repository webhook, for example if you put https://myproxy.com it will generate a webhook URL like this https://myproxy.com/UUID_OF_YOUR_WEBHOOK
161-
# proxyWebhook = "https://myproxy.com"
162-
163-
[vcs.servers.mybitbucket_instance2.bitbucket.Status]
164-
165-
# Set to true if you don't want CDS to push statuses on the VCS server
166-
disable = false
167-
168-
# Set to true if you don't want CDS to push CDS URL in statuses on the VCS server
169-
showDetail = true
170-
31+
version: v1.0
32+
name: bitbucket
33+
type: bitbucketserver
34+
description: "My Bitbucket Datacenter"
35+
url: "http://localhost:7990/bitbucket"
36+
auth:
37+
user: username-on-bitbucket
38+
token: the-long-token-here
39+
options:
40+
disableStatus: false # Set to true if you don't want CDS to push statuses on the VCS server - optional
41+
disableStatusDetails: false # Set to true if you don't want CDS to push CDS URL in statuses on the VCS server - optional
42+
disablePolling: false # Does polling is supported by VCS Server - optional
43+
disableWebHooks: false # Does webhooks are supported by VCS Server - optional
17144
```
17245
173-
See how to generate **[Configuration File]({{<relref "/hosting/configuration.md" >}})**
174-
175-
## Start the vcs µService
176-
177-
```bash
178-
$ engine start vcs
179-
180-
# you can also start CDS api and vcs in the same process:
181-
$ engine start api vcs
46+
```sh
47+
cdsctl experimental project vcs import YOUR_CDS_PROJECT_KEY vcs-bitbucket.yml
18248
```
18349

18450
## Vcs events

docs/content/docs/integrations/bitbucketcloud.md

+38-120
Original file line numberDiff line numberDiff line change
@@ -18,128 +18,46 @@ This integration enables some features:
1818

1919
## How to configure Bitbucket Cloud integration
2020

21-
+ Follow documentation on https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/, section **Create a consumer**
22-
+ Bitbucket requests some informations:
23-
++ **name** you can simply write CDS
24-
++ **description** is optional
25-
++ **callback url** must be the URL of your CDS -> `{CDS_UI_URL}/cdsapi/repositories_manager/oauth2/callback` (if you are in development mode you have to omit /cdsapi and replace {CDS_UI_URL} with your API URL)
26-
++ **URL** is optional.
27-
++ **Permissions** : select `Account Read`, `Workspace membership Read`, `Repositories Read`, `Webhooks Read and Write`
28-
+ Click on Save and toggle the consumer name to see the generated `Key` and `Secret`. It correspond to `clientId` and `clientSecret` in the CDS config.toml file.
29-
30-
### Complete CDS Configuration File
31-
32-
#### VCS µService Configuration
33-
34-
If you don't already have any of vcs integrations on your CDS please follow these steps. The file configuration for the VCS µService can be retreived with:
35-
36-
```bash
37-
$ engine config new vcs > vcs-config.toml
38-
39-
# or with all other configuration parts:
40-
$ engine config new > config.toml
41-
```
42-
43-
Edit the toml file:
44-
45-
- section `[vcs.api]`
46-
- this section will be used to communicate with CDS API. Check the url and the consumer token generated by CDS.
47-
- Token can be generated with cdsctl:
48-
49-
```bash
50-
$ cdsctl consumer new me \
51-
--scopes=Service \
52-
--name="cds-vcs" \
53-
--description="Consumer token for vcs service" \
54-
--groups="" \
55-
--no-interactive
56-
57-
Builtin consumer successfully created, use the following token to sign in:
58-
xxxxxxxx.xxxxxxx.4Bd9XJMIWrfe8Lwb-Au68TKUqflPorY2Fmcuw5vIoUs5gQyCLuxxxxxxxxxxxxxx
59-
```
60-
61-
```toml
62-
[vcs.api]
63-
maxHeartbeatFailures = 10
64-
requestTimeout = 10
65-
## Consumer Token previously generated
66-
token = "xxxxxxxx.xxxxxxx.4Bd9XJMIWrfe8Lwb-Au68TKUqflPorY2Fmcuw5vIoUs5gQyCLuxxxxxxxxxxxxxx"
67-
68-
[vcs.api.http]
69-
# insecure = false
70-
url = "http://localhost:8081"
71-
```
72-
73-
- section `[vcs.ui.http]`
74-
- URL of CDS UI. This URL will be used by Bitbucket Cloud as a callback on Oauth2. This url must be accessible by users' browsers.
75-
76-
```toml
77-
[vcs.ui.http]
78-
url = "http://localhost:8080"
79-
```
80-
81-
- section `[vcs.servers]`
82-
83-
Then add this part to specify you want to add bitbucketcloud integration. Set value to `clientId` and `clientSecret`.
84-
85-
```toml
86-
[vcs.servers]
87-
[vcs.servers.bitbucketcloud]
88-
89-
[vcs.servers.bitbucketcloud.bitbucketcloud]
90-
91-
# Bitbucket Cloud OAuth Key
92-
clientId = "XXXX"
93-
94-
# Bitbucket Cloud OAuth Secret
95-
clientSecret = "XXXX"
96-
97-
# Does webhooks are supported by VCS Server
98-
disableWebHooks = false
99-
100-
# Does webhooks creation are supported by VCS Server
101-
disableWebHooksCreation = false
102-
103-
#proxyWebhook = "https://myproxy.com/"
104-
105-
[vcs.servers.bitbucketcloud.bitbucketcloud.Status]
106-
107-
# Set to true if you don't want CDS to push statuses on the VCS server
108-
disable = false
109-
110-
# Set to true if you don't want CDS to push CDS URL in statuses on the VCS server
111-
showDetail = false
112-
```
113-
114-
#### hooks µService Configuration
115-
116-
If you have not already a hooks µService configured. Then, as the `vcs` µService, you have to configure the `hooks` µService
117-
118-
```bash
119-
$ engine config new hooks > hooks-config.toml
21+
- Follow the section **Create a consumer** on documentation https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/
22+
- Bitbucket requests some informations:
23+
- **name** you can simply write CDS
24+
- **description** is optional
25+
- **callback url** must be the URL of your CDS -> `{CDS_UI_URL}/cdsapi/repositories_manager/oauth2/callback` (if you are in development mode you have to omit /cdsapi and replace {CDS_UI_URL} with your API URL)
26+
- **URL** is optional.
27+
- **Permissions** : select `Account Read`, `Workspace membership Read`, `Repositories Read`, `Pull requests Read`, `Webhooks Read and Write`
28+
- Click on Save and toggle the consumer name to see the generated `Key` and `Secret`. It correspond to `clientId` and `clientSecret` in the CDS config.toml file.
29+
30+
### Create the Personal Access Token on Bitbucket Datacenter
31+
32+
On https://bitbucket.org/account/settings/app-passwords/ create a new app password with the following scopes:
33+
- Account `Email` and `Read`
34+
- Workspace membership `Read`
35+
- Projects `Read`
36+
- Repositories `Read` and `Write`
37+
- Pull requests `Read` and `Write`
38+
- Webhooks `Read and write`
39+
40+
### Import configuration
41+
42+
Create a yml file:
43+
44+
```yaml
45+
version: v1.0
46+
name: bitbucket-cloud
47+
type: bitbucketcloud
48+
description: "My Bitbucket Cloud"
49+
auth:
50+
user: my-user-on-bitbucket-cloud
51+
token: the-long-token-here
52+
options:
53+
disableStatus: false # Set to true if you don't want CDS to push statuses on the VCS server - optional
54+
disableStatusDetails: false # Set to true if you don't want CDS to push CDS URL in statuses on the VCS server - optional
55+
disablePolling: false # Does polling is supported by VCS Server - optional
56+
disableWebHooks: false # Does webhooks are supported by VCS Server - optional
12057
```
12158
122-
In the `[hooks]` section
123-
124-
- check the URL, this will be used by CDS API to call CDS Hooks
125-
- configure `urlPublic` if you want to use [simple Webhook]({{<relref "/docs/concepts/workflow/hooks/webhook.md">}})
126-
- add a name, as `cds-hooks`
127-
128-
In the `[hooks.api]` section
129-
130-
- put the same token as the `[vcs.api]` section
131-
132-
133-
### Start the vcs and hooks µService
134-
135-
*As a CDS Administrator*
136-
137-
```bash
138-
$ engine start vcs --config vcs-config.toml
139-
$ engine start hooks --config hooks-config.toml
140-
141-
# you can also start CDS api and vcs in the same process:
142-
$ engine start api vcs hooks --config config.toml
59+
```sh
60+
cdsctl experimental project vcs import YOUR_CDS_PROJECT_KEY vcs-bitbucketcloud.yml
14361
```
14462

14563
## Vcs events

0 commit comments

Comments
 (0)