public final class GitUtils extends Object
Modifier and Type | Method and Description |
---|---|
static FilePath |
buildFilePath(Run<?,?> run)
Return the FilePath associated with the run instance
|
static FilePath |
buildFilePath(String nodeName,
String workspace)
Return the FilePath based on the Node name and the Workspace.
|
static GitCommitAction |
buildGitCommitAction(Run<?,?> run,
org.jenkinsci.plugins.gitclient.GitClient gitClient,
String gitCommit)
Returns the GitCommitAction of the Run instance.
|
static GitRepositoryAction |
buildGitRepositoryAction(Run<?,?> run,
org.jenkinsci.plugins.gitclient.GitClient gitClient,
EnvVars envVars,
String gitRepositoryURL)
Returns the GitRepositoryAction of the Run instance.
|
static boolean |
isCommitInfoAlreadyCreated(Run<?,?> run,
String gitCommit)
Check if the GitCommitAction has been already created and populated.
|
static boolean |
isRepositoryInfoAlreadyCreated(Run<?,?> run,
String gitRepositoryUrl)
Check if the GitRepositoryAction has been already created and populated.
|
static boolean |
isUserSuppliedGit(Map<String,String> envVars)
Check if the env vars map contains any environment variable with Git information supplied by the user manually.
|
static boolean |
isValidCommit(String gitCommit)
Check if the git commit is a valid commit.
|
static boolean |
isValidRepositoryURL(String gitRepositoryURL)
Check if the git repository URL is a valid repository
|
static org.jenkinsci.plugins.gitclient.GitClient |
newGitClient(Run<?,?> run,
TaskListener listener,
EnvVars envVars,
String nodeName,
String workspace)
Creates a new instance of a
GitClient . |
static String |
resolveGitBranch(Map<String,String> envVars,
BuildData buildData)
Resolve the value for the git branch based
1: Check user supplied env var
2: Check Jenkins env var
3: Check BuildData already calculated
|
static String |
resolveGitCommit(Map<String,String> envVars,
BuildData buildData)
Resolve the value for the git commit sha based
1: Check user supplied env var
2: Check Jenkins env var
3: Check BuildData already calculated
|
static String |
resolveGitRepositoryUrl(Map<String,String> envVars,
BuildData buildData)
Resolve the value for the git repository url based
1: Check user supplied env var
2: Check Jenkins env var
3: Check BuildData already calculated
|
static String |
resolveGitTag(Map<String,String> envVars,
BuildData buildData)
Resolve the value for the git tag based
1: Check user supplied env var
3: Check BuildData already calculated
|
static RepositoryInfo |
searchRepositoryInfo(org.jenkinsci.plugins.gitclient.GitClient gitClient,
EnvVars envVars)
Return the
RepositoryInfo for a certain Git repository. |
static org.eclipse.jgit.revwalk.RevCommit |
searchRevCommit(org.jenkinsci.plugins.gitclient.GitClient gitClient,
String gitCommit)
Return the RevCommit for a certain commit based on the information
stored in a certain workspace of a certain node.
|
public static FilePath buildFilePath(String nodeName, String workspace)
nodeName
- the node name to checkworkspace
- the workspace to build the pathpublic static FilePath buildFilePath(Run<?,?> run)
run
- a particular execution of a Jenkins buildpublic static org.eclipse.jgit.revwalk.RevCommit searchRevCommit(org.jenkinsci.plugins.gitclient.GitClient gitClient, String gitCommit)
gitCommit
- the Git commit SHA to search info.gitClient
- the Git client used.public static RepositoryInfo searchRepositoryInfo(org.jenkinsci.plugins.gitclient.GitClient gitClient, EnvVars envVars)
RepositoryInfo
for a certain Git repository.gitClient
- The Git client to use to obtain the repository informationenvVars
- the env vars available.public static GitCommitAction buildGitCommitAction(Run<?,?> run, org.jenkinsci.plugins.gitclient.GitClient gitClient, String gitCommit)
run
- a particular execution of a Jenkins buildgitClient
- the Git clientgitCommit
- the git commit SHA to usepublic static GitRepositoryAction buildGitRepositoryAction(Run<?,?> run, org.jenkinsci.plugins.gitclient.GitClient gitClient, EnvVars envVars, String gitRepositoryURL)
run
- a particular execution of a Jenkins buildgitClient
- the Git clientenvVars
- the env vars availablegitRepositoryURL
- the git repository URL to usepublic static org.jenkinsci.plugins.gitclient.GitClient newGitClient(Run<?,?> run, TaskListener listener, EnvVars envVars, String nodeName, String workspace)
GitClient
.run
- a particular execution of a Jenkins buildlistener
- the task listenerenvVars
- the env vars availablenodeName
- the node name to use to build the Git clientworkspace
- the workspace to use to build the Git clientpublic static boolean isValidCommit(String gitCommit)
gitCommit
- the git commit to evaluatepublic static boolean isValidRepositoryURL(String gitRepositoryURL)
gitRepositoryURL
- the current git repositorypublic static boolean isRepositoryInfoAlreadyCreated(Run<?,?> run, String gitRepositoryUrl)
run
- the current rungitRepositoryUrl
- the current git respositorypublic static boolean isCommitInfoAlreadyCreated(Run<?,?> run, String gitCommit)
run
- the current rungitCommit
- the git commit to check forpublic static String resolveGitBranch(Map<String,String> envVars, BuildData buildData)
envVars
- the user supplied env varsbuildData
- the build datapublic static String resolveGitCommit(Map<String,String> envVars, BuildData buildData)
envVars
- the user supplied env varsbuildData
- the build datapublic static String resolveGitRepositoryUrl(Map<String,String> envVars, BuildData buildData)
envVars
- the user supplied env varsbuildData
- the build datapublic static String resolveGitTag(Map<String,String> envVars, BuildData buildData)
envVars
- the user supplied environment variablesbuildData
- the build dataCopyright © 2016–2023. All rights reserved.