-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (43 loc) · 1.29 KB
/
index.js
File metadata and controls
55 lines (43 loc) · 1.29 KB
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
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const http = require('https');
const server = express();
server.use(bodyParser.urlencoded({
extended: true
}));
server.use(bodyParser.json());
server.post('/run-pipe', (req, res) => {
const PRBranch = req.body.source.branch.name;
const PRRepo = req.body.source.repository;
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.bitbucket.org",
"port": null,
"path": "/2.0/repositories/koodu_software/" + PRRepo + "/pipelines/?access_token=nPDKvoYW8gWcZOC0GN3moBnl3T0-aAlV7UWlYflePBGy7ULUq5Vu7sWKN7r8bnEQRMDqWk7rVMUythGxemA%3D",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache",
"postman-token": "3aaf9b9f-e9bd-fbee-1219-1512aa8636d0"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ target:
{ ref_type: 'branch',
type: 'pipeline_ref_target',
ref_name: PRBranch } }));
req.end();
});
server.listen((process.env.PORT || 8000), () => {
console.log("Server is up and running...");
});