diff --git a/deploy-this/update-from-git.jenkinsfile b/deploy-this/update-from-git.jenkinsfile index 90daa52..1dee118 100755 --- a/deploy-this/update-from-git.jenkinsfile +++ b/deploy-this/update-from-git.jenkinsfile @@ -1,61 +1,49 @@ def git_remote = "https://git.arti24.eu/gitea" -def projects = [ - "proxy-nginx", - "arti24", - "angular-services", - "arti-angular-app" -] +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" +def git_take(projects, git_remote) { + if (projects.empty) { + sh "git pull" + sh "git log -n 1" + } else { + projects.each { project -> + if (fileExists(project)) { + dir(project) { + sh "git fetch --all && git reset --hard origin/HEAD" } - }else{ - sh "git clone "+git_remote+"/"+project+".git" + } else { + sh "git clone ${git_remote}/${project}.git" } - dir( project ){ - sh( "git log -n 1"); + dir(project) { + sh "git log -n 1" } - - } + } } - } -def disableSafeDirCheck(){ - def disableSafeDirCheck="git config --global --add safe.directory '*'" - sh( disableSafeDirCheck ) +def disableSafeDirCheck() { + sh "git config --global --add safe.directory '*'" } pipeline { - - agent any + agent any stages { stage('Update from git') { steps { - script{ - disableSafeDirCheck() + script { + disableSafeDirCheck() + dir("/_programs_") { + git_take(projects, git_remote) // Dodano git_remote jako argument + } } - dir("/_programs_"){ - script{ - git_take( projects ) - } - } } - } + } } - -} - - +} \ No newline at end of file