public class ScriptVersionStrategy extends VersionStrategy<ScriptVersionStrategy>
ScriptType,
default being ScriptType.GROOVY)
and use the script output as version.
This output must be in CSV format using ';' separator,
with at least the 3 first columns, corresponding to integer values for
major, minor and patch (e.g. 1;2;3).
The script has access to metadata (e.g. In BeanShell for the SHA1 metadata.GIT_SHA1_8).
The script also has access to the environment variables
and system properties, respectively thanks to env
(e.g. env.HOME) and sys (e.g. sys.user.home).
If no script is passed as parameter then the default one is used,
with the same behavior as the PATTERN strategy.VersionStrategy.StrategySearchMode| Constructor and Description |
|---|
ScriptVersionStrategy(VersionNamingConfiguration vnc,
org.eclipse.jgit.lib.Repository repository,
org.eclipse.jgit.api.Git git,
MetadataRegistrar registrar)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Version |
build(Commit head,
List<Commit> parents)
Build a version using the given information extracted from the git repository.
|
ScriptVersionStrategy |
setScript(String script)
Set the script to be interpreted.
|
ScriptVersionStrategy |
setScriptType(ScriptType scriptType)
Set the type of the script (default:
ScriptType.GROOVY). |
computeTagType, enhanceVersionWithBranch, findMaxVersionCommit, findTagToUse, findVersionCommit, getBaseVersionAndRegisterMetadata, getGit, getRegistrar, getRepository, getVersionNamingConfiguration, isBaseCommitOnHead, isGitDirty, isVersionTag, maxVersionTag, maxVersionTag, runAndGetSelf, searchDepthLimit, searchMode, self, setSearchDepthLimit, tagToVersion, toVersionTarget, toVersionTarget, versionFromTagpublic ScriptVersionStrategy(VersionNamingConfiguration vnc, org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.api.Git git, MetadataRegistrar registrar)
vnc - the configuration to userepository - the git repositorygit - a git helper object built from the repositoryregistrar - a storage for found/calculated metadatapublic Version build(Commit head, List<Commit> parents) throws VersionCalculationException
VersionStrategybuild in class VersionStrategy<ScriptVersionStrategy>head - cannot be null the current head commitparents - a non null list of commits that will be involved in version naming.
The list cannot be null and contains the first commit of the repository if no commit with version tag can be found.VersionCalculationException - in case an error occurred while computing the versionpublic ScriptVersionStrategy setScriptType(ScriptType scriptType)
ScriptType.GROOVY).scriptType - the script typepublic ScriptVersionStrategy setScript(String script)
script - the script contentCopyright © 2016–2021 Matthieu Brouillard. All rights reserved.