[DO-550] bbl container create tags (#23)

Reviewed-on: https://git.avroid.tech/DevOps/jenkins-shared-lib/pulls/23
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Co-committed-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
This commit is contained in:
aleksandr.vodyanov
2024-05-28 17:28:06 +03:00
committed by Aleksandr Vodyanov
parent 00ee6c88c3
commit 0233564103

View File

@@ -112,11 +112,12 @@ class Git implements Serializable {
/** /**
* Method executes command "git push" * Method executes command "git push"
* @param String branch - ветка, коммит, тег, который пушится. По умолчанию пустая строка
*/ */
public push() { public push(String branch = '') {
script.sshagent([this.creds]) { script.sshagent([this.creds]) {
script.sh """ script.sh """
git push git push ${branch}
""" """
} }
} }
@@ -135,7 +136,7 @@ class Git implements Serializable {
* Method executes command "git log". * Method executes command "git log".
* @param Map args: * @param Map args:
* - int Count: count of commits * - 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 = [:]) { public String log(Map args = [:]) {
Map defaultArgs = [ 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() 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()
}
} }