This Java example aggregates and counts builds from the last 24 hours by username.
This sample uses version 2 of the Export API, available since Develocity 2021.2.
In order to use it with older Develocity versions, please modify all occurrences of /build-export/v2
to /build-export/v1
in ExportApiJavaExample.java
.
To run this sample:
- Replace the hostname value of the
DEVELOCITY_SERVER_URL
constant inExportApiJavaExample.java
with your Develocity hostname. - Set the appropriate authentication environment variables (see below).
- Run
./gradlew run
from the command line.
We recommend using the Bearer token authentication which has been available since Develocity 2021.1.
- Create a Develocity access key for a user with the
Export API
role as described in the Export API Access Control documentation. - Set an environment variable locally:
EXPORT_API_ACCESS_KEY
to match the newly created Develocity access key.
Non-SAML users can authenticate via basic auth.
- Create a Develocity user with the
Export API
role as described in the Export API Access Control documentation. - Set two environment variables locally:
EXPORT_API_USER
EXPORT_API_PASSWORD
to match the newly created Export API user credentials.
Streaming builds...
Streaming events for : tlau2phsbmpl4
Streaming events for : gyj4ue5rkfhes
...
Streaming events for : lgxfpx2rniy26
Streaming events for : zakj2zjtnv27k
Streaming events for : 2bbnxgrcq5uco
Results: [user1: 80, user2: 64, build-agent1: 480, user3: 77, build-agent2: 598]