From cb3c07368194df3a2dee89fc90ef25a7719d6f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Ku=C5=9B?= Date: Thu, 4 Sep 2025 11:19:13 +0200 Subject: [PATCH] adding credintials id --- deploy-this/update-from-git.jenkinsfile | 31 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/deploy-this/update-from-git.jenkinsfile b/deploy-this/update-from-git.jenkinsfile index 895a605..3218408 100755 --- a/deploy-this/update-from-git.jenkinsfile +++ b/deploy-this/update-from-git.jenkinsfile @@ -8,16 +8,25 @@ def projects = [ ] def git_take(projects, git_remote) { - projects.each { project -> - if (fileExists(project)) { - dir(project) { - sh "git fetch --all && git reset --hard origin/HEAD" + withCredentials([usernamePassword(credentialsId: 'c3c1f5bf-8f6e-4686-b26c-3f419ef7973e', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) { + projects.each { project -> + if (fileExists(project)) { + dir(project) { + sh """ + echo "=== Updating ${project} ===" + git fetch https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git --all + git reset --hard origin/main + """ + } + } else { + sh """ + echo "=== Cloning ${project} ===" + git clone https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git + """ + } + dir(project) { + sh "git --no-pager log -n 1 --pretty=format:'%h %ad %s' --date=short" } - } else { - sh "git clone ${git_remote}/${project}.git" - } - dir(project) { - sh "git log -n 1" } } } @@ -35,10 +44,10 @@ pipeline { script { disableSafeDirCheck() dir("/_sd_/_programs_") { - git_take(projects, git_remote) // Dodano git_remote jako argument + git_take(projects, git_remote) } } } } } -} \ No newline at end of file +}