Skip to content

Commit 1dede3c

Browse files
authored
Update README for new access key and URL settings (#457)
Finalizes #338. Related to #455, #468.
1 parent a4bd526 commit 1dede3c

File tree

5 files changed

+62
-30
lines changed

5 files changed

+62
-30
lines changed

README.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,31 @@ This library [fixes][34] those issues in generated code, implements [paging][24]
2828

2929
## Setup
3030

31-
Set up environment variables and use the library from any notebook, script or project:
31+
Set up once and use the library from any notebook, script or project:
3232

33-
- [`DEVELOCITY_API_URL`][16]: the URL of your Develocity instance
34-
- [`DEVELOCITY_API_TOKEN`][17]: an [access key][31] for the Develocity instance
33+
- [`DEVELOCITY_URL`][16]: the URL of your Develocity instance
3534
- [`DEVELOCITY_API_CACHE_ENABLED`][12] (optional, off by default): enables caching for some
3635
requests (see [caveats][13])
36+
- An access key in one of the supported locations
37+
38+
<details>
39+
40+
<summary>Supported access key locations</summary>
41+
42+
Access key support matches that of official tooling: the Develocity [Gradle Plugin][37] and [Maven Extension][38].
43+
If you've already provisioned a key for your build to connect to Develocity, there's probably no action needed.
44+
Supported locations, in order of precedence:
45+
46+
- a provider function as [`Config.accessKey`][17] (see [optional setup](#optional-setup))
47+
- official tooling locations with value in format `host=key`, e.g. `DEVELOCITY_ACCESS_KEY='foo.com=my-key'`:
48+
- [`DEVELOCITY_ACCESS_KEY`](https://docs.gradle.com/develocity/gradle-plugin/current/#manual_access_key_configuration)
49+
- [`GRADLE_ENTERPRISE_ACCESS_KEY`](https://docs.gradle.com/develocity/gradle-plugin/current/#manual_access_key_configuration)
50+
- File `$GRADLE_USER_HOME/.gradle/develocity/keys.properties`, or `~/.gradle/develocity/keys.properties` if `GRADLE_USER_HOME` is not set
51+
- File `~/.m2/.develocity/keys.properties`
52+
53+
Refer to the Develocity [Gradle Plugin User Manual][37] or [Maven Extension User Manual][38] for details on these variables and files, including support for keys of multiple hosts.
54+
55+
</details>
3756

3857
### Setup snippets
3958

@@ -177,8 +196,8 @@ your own. For example:
177196

178197
```kotlin
179198
val config = Config(
180-
apiUrl = "https://ge.mycompany.com/api/",
181-
apiToken = { vault.getGeApiToken() },
199+
develocityUrl = "https://ge.mycompany.com/",
200+
accessKey = { vault.getDevelocityAccessKey() },
182201
clientBuilder = existingClient.newBuilder(),
183202
)
184203
val api = DevelocityApi.newInstance(config)
@@ -219,8 +238,8 @@ For general discussions or questions, feel free to reach out to maintainers on t
219238
[12]: https://gabrielfeo.github.io/develocity-api-kotlin/library/com.gabrielfeo.develocity.api/-config/-cache-config/cache-enabled.html
220239
[13]: https://gabrielfeo.github.io/develocity-api-kotlin/library/com.gabrielfeo.develocity.api/-config/-cache-config/index.html
221240
[14]: https://central.sonatype.com/artifact/com.gabrielfeo/develocity-api-kotlin/2024.3.0
222-
[16]: https://gabrielfeo.github.io/develocity-api-kotlin/library/com.gabrielfeo.develocity.api/-config/api-url.html
223-
[17]: https://gabrielfeo.github.io/develocity-api-kotlin/library/com.gabrielfeo.develocity.api/-config/api-token.html
241+
[16]: https://gabrielfeo.github.io/develocity-api-kotlin/library/com.gabrielfeo.develocity.api/-config/server.html
242+
[17]: https://gabrielfeo.github.io/develocity-api-kotlin/library/com.gabrielfeo.develocity.api/-config/access-key.html
224243
[18]: https://gabrielfeo.github.io/develocity-api-kotlin/library/com.gabrielfeo.develocity.api/-builds-api/index.html
225244
[19]: https://gabrielfeo.github.io/develocity-api-kotlin/library/com.gabrielfeo.develocity.api.model/-gradle-attributes/index.html
226245
[20]: https://gabrielfeo.github.io/develocity-api-kotlin/library/com.gabrielfeo.develocity.api/-builds-api/index.html
@@ -240,3 +259,5 @@ For general discussions or questions, feel free to reach out to maintainers on t
240259
[34]: https://github.com/gabrielfeo/develocity-api-kotlin/blob/main/build-logic/src/functionalTest/kotlin/com/gabrielfeo/task/PostProcessGeneratedApiTest.kt#L21
241260
[35]: https://community.gradle.org/#community-channels
242261
[36]: ./examples/example-gradle-task/
262+
[37]: https://docs.gradle.com/develocity/gradle-plugin/current/#manual_access_key_configuration
263+
[38]: https://docs.gradle.com/develocity/maven-extension/current/#manual_access_key_configuration

docs/AccessKeys.md

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
1-
# Access key / API token
1+
# Access keys
22

3-
[All API requests require authentication][1]. Provide a valid access key of your Develocity instance
4-
as the `DEVELOCITY_API_TOKEN` environment variable.
3+
API requests may require [authentication][1].
54

6-
## How to get an access key
5+
## Anonymous access
76

8-
1. Sign in to Develocity (with a user that has “Export build data” permission)
9-
2. Go to "My settings" from the user menu in the top right-hand corner of the page
10-
3. Go to "Access keys" from the sidebar
11-
4. Click "Generate" on the right-hand side
12-
5. Set key as the `DEVELOCITY_API_TOKEN` environment variable when using the library
7+
If your Develocity server is configured to allow [anonymous access][2] for permission "Access build data via the API", then an access key is not required to use this library.
8+
This is often the case for a server only accessible from a private network.
139

14-
## Migrating from macOS keychain support
10+
![Anonymous access settings](media/AnonymousAccessPage.png)
1511

16-
This library used to support storing the key in the macOS keychain as `gradle-enterprise-api-kotlin`.
17-
This feature was deprecated in 2023.4.0, then removed in 2024.1.1. You may use the method of your choice
18-
(secret managers, password manager CLIs, etc.) to store and retrieve the key to an environment.
12+
## Authenticated access
1913

20-
If you used the key from keychain and need a drop-in replacement:
14+
The library will automatically resolve the access key using the same conventions as official Develocity tooling, in order:
2115

22-
```
23-
# Create an alias in your shell to fetch the key from keychain
24-
echo 'alias dat="security find-generic-password -w -a "$LOGNAME" -s gradle-enterprise-api-kotlin"' >> ~/.zshrc
16+
- Environment variable `DEVELOCITY_ACCESS_KEY`
17+
- Environment variable `GRADLE_ENTERPRISE_ACCESS_KEY`
18+
- File `$GRADLE_USER_HOME/.gradle/develocity/keys.properties` (or `~/.gradle/develocity/keys.properties` if `GRADLE_USER_HOME` is not set)
19+
- File `~/.m2/.develocity/keys.properties`
2520

26-
# Retrieve it to the environment variable before running the program
27-
DEVELOCITY_API_TOKEN="$(dat)" ./my-script.main.kts
28-
DEVELOCITY_API_TOKEN="$(dat)" jupyter lab
29-
DEVELOCITY_API_TOKEN="$(dat)" idea my-project
30-
```
21+
Please check if you already have an access key set up in your build environment for the Develocity server you want to query. The first key for a matching host will be used, if found.
22+
23+
See the official manuals for instructions on how to set up a new access key in one of these locations:
24+
25+
- [Develocity Gradle Plugin User Manual][3]
26+
- [Develocity Maven Extension User Manual][4]
27+
- [Develocity sbt Plugin User Manual][5]
28+
- [Develocity npm Agent User Manual][6]
29+
- [Develocity Python Agent User Manual][7]
30+
31+
### User permissions
32+
33+
To call the API, the user from which the access key was generated must have the "Access build data via the API" permission.
34+
35+
![User permissions](media/AccessPage.png)
3136

3237
[1]: https://docs.gradle.com/enterprise/api-manual/#access_control
38+
[2]: https://docs.gradle.com/develocity/helm-admin/current/#_anonymous_access
39+
[3]: https://docs.gradle.com/develocity/gradle-plugin/current/#manual_access_key_configuration
40+
[4]: https://docs.gradle.com/develocity/maven-extension/current/#manual_access_key_configuration
41+
[5]: https://gradle.com/help/sbt-plugin-authenticating
42+
[6]: https://gradle.com/help/npm-agent-authenticating
43+
[7]: https://gradle.com/help/python-agent-authenticating

docs/media/AccessPage.png

292 KB
Loading

docs/media/AnonymousAccessPage.png

298 KB
Loading

examples/example-notebooks/MostFrequentBuilds.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"source": [
1010
"# Most frequent builds\n",
1111
"\n",
12-
"See what builds are most commonly invoked by developers, e.g. `clean assemble`, `test` or `check`. You can [set up the URL and a token for your Develocity instance](https://github.com/gabrielfeo/develocity-api-kotlin/blob/main/README.md#setup) and run this notebook as-is for your own project.\n",
12+
"See what builds are most commonly invoked by developers, e.g. `clean assemble`, `test` or `check`. You can [set up the URL and an access key for your Develocity instance](https://github.com/gabrielfeo/develocity-api-kotlin/blob/main/README.md#setup) and run this notebook as-is for your own project.\n",
1313
"\n",
1414
"This is a simple example of something you can do with the API. It could bring insights, for example:\n",
1515
"\n",

0 commit comments

Comments
 (0)