def git_remote = "https://git.arti24.eu/gitea" def projects = [ "proxy-nginx", "arti24", "angular-services", "arti-angular-app" ] def git_take( projects, git_remote ){ if( 0 == projects.size() ){ def git_pull ="git pull" sh( git_pull ) sh("git log -n 1") }else{ for( project in projects ){ if( fileExists( project ) ){ dir( project ){ sh "git fetch --all && git reset --hard origin/HEAD" } }else{ sh "git clone "+git_remote+"/"+project+".git" } dir( project ){ sh( "git log -n 1"); } } } } def disableSafeDirCheck(){ def disableSafeDirCheck="git config --global --add safe.directory '*'" sh( disableSafeDirCheck ) } pipeline { agent any stages { stage('Update from git') { steps { script{ disableSafeDirCheck() } dir("/_programs_"){ script{ git_take( projects ) } } } } } }