Bezpiecznie używał poświadczeń (withCredentials) – hasło nie wycieknie w
logach. Obsługiwał aktualizację istniejących katalogów i klonowanie nowych. Pobierał tylko ostatni rok historii (--shallow-since="1 year ago"). Nie zostawiał pustych katalogów, jeśli klon się nie powiedzie.
This commit is contained in:
parent
2756d0042e
commit
3fec7091ba
|
|
@ -10,25 +10,28 @@ def projects = [
|
||||||
def git_take(projects, git_remote) {
|
def git_take(projects, git_remote) {
|
||||||
withCredentials([usernamePassword(credentialsId: 'c3c1f5bf-8f6e-4686-b26c-3f419ef7973e', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) {
|
withCredentials([usernamePassword(credentialsId: 'c3c1f5bf-8f6e-4686-b26c-3f419ef7973e', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) {
|
||||||
projects.each { project ->
|
projects.each { project ->
|
||||||
|
def projectPath = "${env.WORKSPACE}/${project}"
|
||||||
|
|
||||||
if (fileExists(project)) {
|
if (fileExists(project)) {
|
||||||
dir(project) {
|
dir(project) {
|
||||||
sh """
|
sh """
|
||||||
echo "=== Updating ${project} ==="
|
echo "=== Updating ${project} ==="
|
||||||
|
git config --global --add safe.directory \$(pwd)
|
||||||
git remote set-url origin https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git
|
git remote set-url origin https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git
|
||||||
git fetch origin
|
git fetch --depth=1000 origin main
|
||||||
git reset --hard origin/main
|
git reset --hard origin/main
|
||||||
"""
|
"""
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sh """
|
sh """
|
||||||
git clone https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git || exit 1
|
echo "=== Cloning ${project} (last year only) ==="
|
||||||
|
git clone --shallow-since="1 year ago" https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git
|
||||||
"""
|
"""
|
||||||
if (!fileExists(project)) {
|
if (!fileExists(project)) {
|
||||||
error("Nie udało się pobrać lub utworzyć katalogu projektu ${project}")
|
error("❌ Nie udało się sklonować repozytorium ${project}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
dir(project) {
|
dir(project) {
|
||||||
sh "git --no-pager log -n 1 --pretty=format:'%h %ad %s' --date=short"
|
sh "git --no-pager log -n 1 --pretty=format:'%h %ad %s' --date=short"
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +39,6 @@ def git_take(projects, git_remote) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def disableSafeDirCheck() {
|
def disableSafeDirCheck() {
|
||||||
sh "git config --global --add safe.directory '*'"
|
sh "git config --global --add safe.directory '*'"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue