workspace jenkins to _sd_

This commit is contained in:
Artur Kuś 2025-09-04 23:14:18 +02:00
parent b8b2bfbd55
commit c1447b3d15
1 changed files with 30 additions and 24 deletions

View File

@ -10,39 +10,45 @@ def projects = [
def programs = "/_sd_/_programs_" def programs = "/_sd_/_programs_"
def git_take(projects, git_remote) { def git_take(projects, git_remote) {
withCredentials([usernamePassword(credentialsId: '9e8daaa4-8c14-41ae-947b-65ba47965dfe', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) { withCredentials([usernamePassword(
dir(programs) { credentialsId: '9e8daaa4-8c14-41ae-947b-65ba47965dfe',
projects.each { project -> usernameVariable: 'GIT_USER',
if (fileExists(project)) { passwordVariable: 'GIT_PASS')]) {
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 --prune origin
git checkout -B main origin/main
"""
}
} else {
sh """
echo "=== Cloning ${project} (last year only) ==="
git clone --shallow-since="1 year ago" https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git ${project}
"""
dir(project) {
sh "git config --global --add safe.directory \$(pwd)"
}
}
projects.each { project ->
if (fileExists(project)) {
dir(project) { dir(project) {
sh "git --no-pager log -n 1 --pretty=format:'%h %ad %s' --date=short" 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 --prune origin
git checkout -B main origin/main
"""
} }
} else {
sh """
echo "=== Cloning ${project} (last year only) ==="
git clone --shallow-since="1 year ago" https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git ${project}
"""
dir(project) {
sh "git config --global --add safe.directory \$(pwd)"
}
}
dir(project) {
sh "git --no-pager log -n 1 --pretty=format:'%h %ad %s' --date=short"
} }
} }
} }
} }
pipeline { pipeline {
agent any agent {
any
customWorkspace programs
}
stages { stages {
stage('Update from git') { stage('Update from git') {
steps { steps {