This repository demonstrates using the Gradle Enterprise API and generating client code from its OpenAPI specification.
The sample observes builds being published to the given Gradle Enterprise instance in real-time and prints basic attributes along with build cache performance metrics.
Execute:
$ ./gradlew install
This builds and installs the program into build/install/gradle-enterprise-api-samples
.
You can use the build/install/gradle-enterprise-api-samples/bin/gradle-enterprise-api-samples
script to run the sample.
A Gradle Enterprise access key with the “Export build data via the API” permission is required.
To create an access key:
- Sign in to Gradle Enterprise.
- Access "My settings" from the user menu in the top right-hand corner of the page.
- Access "Access keys" from the left-hand menu.
- Click "Generate" on the right-hand side and copy the generated access key.
The access key should be saved to a file, which will be supplied as a parameter to the program.
Next, execute:
$ build/install/gradle-enterprise-api-samples/bin/gradle-enterprise-api-samples --server-url=«serverUrl» --access-key-file=«accessKeyFile» --project-name=«projectName»
«serverUrl»
: The address of your Gradle Enterprise server (e.g.https://ge.example.com
)«accessKeyFile»
: The path to the file containing the access key«projectName»
(optional): The name of the project to limit reporting to (reports all builds when omitted)«maxBuilds»
(optional): The maximum number of builds to return by a single query. The number may be lower if --max-wait-secs is reached (default - 100)«maxWaitSecs»
(optional): The maximum number of seconds to wait until a query returns. If the query returns before --max-builds is reached, it returns with already processed builds (default - 3)
The program will print Processing builds ...
, then indefinitely listen for any new builds being published to Gradle Enterprise and print basic information about each build to the console.
To stop the program, use Ctrl + C.
The sample code can be found here.
The Gradle Enterprise API manual and reference documentation for each version of the API can be found here.
The Gradle Enterprise API Samples project is open-source software released under the Apache 2.0 License.