adding credintials id

This commit is contained in:
Artur Kuś 2025-09-04 11:19:13 +02:00
parent a4f5f585ed
commit cb3c073681
1 changed files with 20 additions and 11 deletions

View File

@ -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,7 +44,7 @@ pipeline {
script {
disableSafeDirCheck()
dir("/_sd_/_programs_") {
git_take(projects, git_remote) // Dodano git_remote jako argument
git_take(projects, git_remote)
}
}
}