diff --git a/deploy-this/update-from-git.jenkinsfile b/deploy-this/update-from-git.jenkinsfile index 1338134..0bf1d9f 100755 --- a/deploy-this/update-from-git.jenkinsfile +++ b/deploy-this/update-from-git.jenkinsfile @@ -10,25 +10,28 @@ def projects = [ def git_take(projects, git_remote) { withCredentials([usernamePassword(credentialsId: 'c3c1f5bf-8f6e-4686-b26c-3f419ef7973e', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) { projects.each { project -> + def projectPath = "${env.WORKSPACE}/${project}" + if (fileExists(project)) { dir(project) { sh """ 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 fetch origin + git fetch --depth=1000 origin main git reset --hard origin/main """ - } } else { 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)) { - error("Nie udało się pobrać lub utworzyć katalogu projektu ${project}") + error("❌ Nie udało się sklonować repozytorium ${project}") } - } + dir(project) { 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() { sh "git config --global --add safe.directory '*'" }