def projects = [ "proxy-nginx", "arti24", "angular-services", "arti-angular-app" ] pipeline { agent any // NAJBEZPIECZNIEJSZA OPCJA stages { stage('Update Git Repositories') { steps { dir('/_sd_/_programs_') { script { withCredentials([usernamePassword( credentialsId: '9e8daaa4-8c14-41ae-947b-65ba47965dfe', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) { projects.each { project -> if (fileExists(project)) { dir(project) { sh """ git config --global --add safe.directory \$(pwd) git remote set-url origin https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/arti24/${project}.git git fetch --prune origin git checkout -B main origin/main echo "--- Last commit for ${project} ---" git log -1 --pretty=format:"Date: %cd%nMessage: %s" echo "-------------------------------------" """ } } else { sh """ git clone --shallow-since="1 month ago" https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/arti24/${project}.git ${project} """ } } } } } } } } }