Respond to events in your build pipeline and keep your main branch stable.
500K+
Respond to events in your build pipeline and keep your main branch stable.
Examples:
Clerk has a powerful DSL that lets you customise your rules:
if (failuresForCommitOnBranch <= 2) {
rebuildBranch()
} else {
revertCommit()
lockBranch()
}
publishAnalysis("general")
This is just a taste of what you can do. See the examples in the
parsermodule's tests for more, or read on to learn about the events supported.
Currently, you can react to the following events:
buildFailed - a build just failedbranchStartsFailing - a formerly passing branch just failedbuildPassed - a build just passedbranchStartsPassing - a formerly failing branch just passedrepository - repository wide rules - good for setting maximum thresholds for things like failures on a branchpullRequestMerged - a pull request was mergedWith Clerk's DSL, you can perform arbitrary logic in response to build events. Once you've figured out how you want to react, you do things like:
In addition, you can post an arbitrary message to a Slack channel of your choice, in case you need to notify people of something or cajole someone into action.
Run using Docker:
docker run --rm -it -p9090:9090 outofcoffee/build-clerk
See http://localhost:9090 to check it's running.
RULES_FILE (required) - path to rules file to respond to build lifecycle eventsSlack configuration:
SLACK_USER_TOKEN - a token with the chat.write permissionJenkins configuration:
JENKINS_BASE_URL - base URL for Jenkins serverJENKINS_USERNAME - username for JenkinsJENKINS_PASSWORD - API key or password for JenkinsBitbucket configuration:
BITBUCKET_REPO_USERNAME - the username for the Bitbucket repository's user (might be a organisation)BITBUCKET_REPO_SLUG - the 'repo slug' name for the Bitbucker repositoryBITBUCKET_AUTH_USERNAME - the username to authenticate with Bitbucket (if it differs from the repository username)BITBUCKET_PASSWORD - the password (preferably an 'app password') to authenticate with BitbucketGlobal filters:
FILTER_BRANCHES - only process events for this SCM branchFILTER_REPOS - only process events from this repository (applies to PRs only)Security configuration:
AUTH_CONFIG_FILE - path to Shiro properties file for HTTP Basic authenticationAdvanced configuration:
SERVER_PORT - the HTTP port on which to listenBy default, Clerk uses an in-memory data store for build reports. This will not persist between application restarts, but is good for testing/evaluation purposes.
To switch to a persistent, MongoDB based store, set the following environment variables:
STORE_IMPL=mongo
MONGO_HOST=localhost
MONGO_PORT=27017
Set the host and port variables to those of your MongoDB instance.
For some analyses, Clerk can examine the commits in your source repository.
In order for this to work, Clerk must have access to a bare Git repository, or be authenticated to clone one.
The relevant configuration variables for working with the source repository are:
GIT_REPO_LOCAL_DIR - path to a local repository cloneGIT_REPO_REMOTE_URL - the remote URL of the repository.GIT_REPO_USERNAME - used for HTTP(S) remote repository URLs onlyGIT_REPO_PASSWORD - used for HTTP(S) remote repository URLs, or, optionally with SSH URLs where a public key is not usedIf you choose to use the revertCommit action, you'll also need to set the following configuration variable:
GIT_REPO_PUSH_CHANGES (default: false) - whether to push changes to the remoteIf this is set to
false, any changes will not be pushed to the remote repository. This can be useful for testing.
For SSH URLs, Clerk uses the configuration of the machine on which it is running. This means your local SSH configuration (public key etc.) is used.
For HTTP(S) URLs, Clerk looks for the configured username and password, or else assumes the remote repository is unauthenticated.
Clerk exposes different endpoints on which it can receive different event types.
Jenkins build reports, sent by either the Notification Plugin, or the Clerk Plugin Jenkins plugins should target:
/builds
Example: https://clerk.example.com/builds
Slack interactive message callbacks should target:
/actions
Example: https://clerk.example.com/actions
Bitbucket webhooks for the 'Pull request merged' event should target:
/pull-requests/merged
You can (and should!) set up authentication for these endpoints to prevent others from accessing your Clerk instance.
To do this, you can either use the built-in HTTP Basic Auth functionality in Clerk, or put in place an authenticating reverse proxy (out of scope of this document).
To use Clerk's HTTP Basic Auth functionality, set the AUTH_CONFIG_FILE environment variable to the path of a Shiro properties file.
Tip: for an example file, see
backend/examples/clerk-auth.properties
When you are configuring the various third parties to call back Clerk, you can enter the callback/webhook URLs with inline credentials to match those in your Shiro properties.
For example:
https://someuser:[email protected]/actions
Content type
Image
Digest
sha256:61e1428b9…
Size
166.6 MB
Last updated
over 3 years ago
docker pull outofcoffee/build-clerk