From 0233564103fa5195c16c73b0d79c5f8a6e2af509 Mon Sep 17 00:00:00 2001 From: "aleksandr.vodyanov" Date: Tue, 28 May 2024 17:28:06 +0300 Subject: [PATCH] [DO-550] bbl container create tags (#23) Reviewed-on: https://git.avroid.tech/DevOps/jenkins-shared-lib/pulls/23 Co-authored-by: aleksandr.vodyanov Co-committed-by: aleksandr.vodyanov --- src/tech/avroid/scm/Git.groovy | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/tech/avroid/scm/Git.groovy b/src/tech/avroid/scm/Git.groovy index 0a087c5..6ad2444 100644 --- a/src/tech/avroid/scm/Git.groovy +++ b/src/tech/avroid/scm/Git.groovy @@ -112,11 +112,12 @@ class Git implements Serializable { /** * Method executes command "git push" + * @param String branch - ветка, коммит, тег, который пушится. По умолчанию пустая строка */ - public push() { + public push(String branch = '') { script.sshagent([this.creds]) { script.sh """ - git push + git push ${branch} """ } } @@ -135,7 +136,7 @@ class Git implements Serializable { * Method executes command "git log". * @param Map args: * - int Count: count of commits - * - String format: format of output (see git log --help) + * - String format: format of output (see git log --help) */ public String log(Map args = [:]) { Map defaultArgs = [ @@ -155,4 +156,29 @@ class Git implements Serializable { return this.script.sh(script: "git log -n $args.count $args.format", returnStdout: true).trim() } + + /** + * Method executes command "git tag". + * @param Map args: + * - String tagName: имя тега + * - String pointsAt: просмотр тегов на определенном коммите + */ + public String tag(Map args = [:]) { + Map defaultArgs = [ + tagName: '', + pointsAt: '', + ] + + defaultArgs.each { k, v -> + if (args[k] == null || args[k] == '' || args[k] == []) { + args[k] = v + } + } + + if (args.pointsAt != '') { + args.pointsAt = "--points-at ${args.pointsAt}" + } + + return this.script.sh(script: "git tag $args.tagName $args.pointsAt", returnStdout: true).trim() + } }