-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevelocity.config.cjs
More file actions
75 lines (67 loc) · 1.82 KB
/
Copy pathdevelocity.config.cjs
File metadata and controls
75 lines (67 loc) · 1.82 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* eslint-disable @typescript-eslint/no-require-imports */
const {
fromPropertiesFile,
inGradleUserHome
} = require('@gradle-tech/develocity-agent/api/config')
const { execSync } = require('node:child_process')
module.exports = {
projectId: 'cavendish-github-actions',
server: {
url: 'https://develocity.grdev.net',
accessKey: fromPropertiesFile(inGradleUserHome())
},
buildScan: {
capture: {
testLogging: true
},
obfuscation: {
ipAddresses: (f) =>
f.length > 1 ? f.substring(0, f.lastIndexOf('.')) + '.0' : f
},
...buildScanUserData()
}
}
function buildScanUserData() {
const links = {}
const tags = []
const values = {}
// some CI environments will expose the build url
// as an environment variable
const buildUrl = process.env.BUILD_URL
// get last commit id
const commitId = outputOf('git rev-parse HEAD')
// get current branch name
const branch = outputOf('git branch --show-current')
// check if there are uncommitted changes
const dirty = outputOf('git status --porcelain')
if (buildUrl !== undefined) {
links['TeamCity build'] = buildUrl
}
if (commitId !== undefined) {
values['Git commit id'] = commitId
// use your Develocity URL to add proper links
links['Git Commit Build Scans'] =
`https://develocity.grdev.net/scans?search.names=Git+commit+id&search.values=${commitId}`
}
// decide if it's a CI run or local run
tags.push(process.env.CI !== undefined ? 'CI' : 'Local')
if (branch !== undefined) {
tags.push(branch)
}
if (dirty) {
tags.push('Dirty')
}
return {
links,
tags,
values
}
}
function outputOf(command) {
try {
return execSync(command, { encoding: 'utf-8' }).toString().trim()
} catch {
// ignore errors, most likely the command is not available
return undefined
}
}