You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 5, 2018. It is now read-only.
Andrew Oberstar edited this page Nov 12, 2016
·
11 revisions
For typical use cases of interacting with a Git repo, you should apply the org.ajoberstar.grgit plugin. This plugin makes a grgit property available to all projects (so you should only apply it once). It will be configured to search for a repo as if you had a console open to the rootDir of the build's root project, and we're using the Git CLI.
Once you have the plugin applied, you can create your own tasks or otherwise interact with the Git repo, as needed.
version ="1.0.0-${grgit.head().abbreviatedId}"
task tagRelease {
description ='Tags the current head with the project\'s version.'
doLast {
grgit.tag.add {
name = version
message ="Release of ${version}"
}
}
}
task pushToOrigin {
description ='Pushes current branch\'s committed changes to origin repo.'
doLast {
grgit.push()
}
}
For details on the available methods/properties see the API docs of
Grgit.
Examples of how to use each operation are provided there.
Authentication
Grgit provides multiple ways to authenticate with remote repositories. If using hardcoded credentials, it is suggested to use the system properties rather than including them in the repository.
See Grgit's AuthConfig docs for information on the
various authentication options.
Methods that produce a Grgit instance, which includes clone, init, and open, all take a Credentials instance if
you want to provide hardcoded credentials programmatically.