Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_git_branches(url, secretfileId) {
- def isport = url.split(':'); def port = ''
- if (isport.size() >= 3) {
- port = '-p ' + isport[2].split('/')[0]
- }
- def revisions_list = []; def branches = []
- withCredentials([[$class: 'FileBinding', credentialsId: secretfileId, variable: 'GITLAB_SSH_KEY']]) {
- revisions_list = sh(returnStdout: true, script: "GIT_SSH_COMMAND='ssh $port -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i $GITLAB_SSH_KEY' git ls-remote -t -h $url").split('\r?\n')
- }
- for (def revision in revisions_list) {
- def branch = revision.split('\t')[1].replaceAll('refs/heads/', '').replaceAll('refs/tags/', '').replaceAll(/[\^].*/, '')
- branches.add(branch)
- }
- return branches.unique()
- }
- ....
- def configs_branches = get_git_branches(configs_repo_url, gitlab_secretfileId)
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement