Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Latest commit

 

History

History
67 lines (48 loc) · 3.05 KB

gitTools.md

File metadata and controls

67 lines (48 loc) · 3.05 KB

gitTools

This part of the pipeline provides utility steps for common GIT operations.

Table of contents

mirrorRepository(String srcUrl, String targetUrl, List<String> srcCredentialIds = null, List<String> targetCredentialIds = null)

This step is a combination of:

This steps mirrors a GIT repository from srcUrl to targetUrl When no srcCredentialIds or targetCredentialIds are provided a auto lookup of the SSH or http(s) credentials will be performed.

mirrorRepositoryToRemote(String srcRepoPath, GitRepository targetRepo, List<String> targetCredentialIds = null)

Mirrors a local bare cloned repository form $WORKSPACE/$srcRepoPath to the targetRepo. When no targetCredentialIds are provided a auto lookup of the SSH or http(s) credentials will be performed.

mirrorRepositoryToWorkspace(GitRepository srcRepo, List<String> srcCredentialIds = null)

Mirrors the srcRepo to the current workspace. When no srcCredentialIds are provided a auto lookup of the SSH or http(s) credentials will be performed.

String getBranch()

Utility function to get the name of the branch. It will try to retrieve the name in the following order:

  • environment variable GIT_BRANCH
  • environment variable GIT_LOCAL_BRANCH
  • environment variable BRANCH_NAME
  • short git commit hash

The result will be stored in the GIT_BRANCH environment variable if the GIT_BRANCH environment variable is not already set.

String getFetchOrigin(String remotes = null)

Utility function to get the fetch origin from a git remote list (git remote -v). When no remotes are provided the step will try to retrieve them by using the internal function _getRemotes which basically executes a git remote -v.

String getPushOrigin(String remotes = null)

Utility function to get the push origin from a git remote list (git remote -v). When no remotes are provided the step will try to retrieve them by using the internal function _getRemotes which basically executes a git remote -v.

String getParentBranch()

Utility function to get the name of the parent branch. At the moment this is limited to the following logic:

  1. Use origin/develop when branch exists
  2. Use origin/master when branch exists
  3. Fallback to null