56 lines
1.5 KiB
Plaintext
Executable File
56 lines
1.5 KiB
Plaintext
Executable File
def git_remote = "https://git.arti24.eu/gitea"
|
|
|
|
def projects = [
|
|
"proxy-nginx",
|
|
"arti24",
|
|
"angular-services",
|
|
"arti-angular-app"
|
|
]
|
|
|
|
def git_take(projects, git_remote) {
|
|
withCredentials([usernamePassword(credentialsId: 'c3c1f5bf-8f6e-4686-b26c-3f419ef7973e', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) {
|
|
projects.each { project ->
|
|
if (fileExists(project)) {
|
|
dir(project) {
|
|
sh '''
|
|
echo "=== Updating ${project} ==="
|
|
git remote set-url origin https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git
|
|
git fetch origin
|
|
git reset --hard origin/main
|
|
'''
|
|
}
|
|
} else {
|
|
sh '''
|
|
echo "=== Cloning ${project} ==="
|
|
git clone https://${GIT_USER}:${GIT_PASS}@git.arti24.eu/gitea/${project}.git
|
|
'''
|
|
}
|
|
dir(project) {
|
|
sh "git --no-pager log -n 1 --pretty=format:'%h %ad %s' --date=short"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
def disableSafeDirCheck() {
|
|
sh "git config --global --add safe.directory '*'"
|
|
}
|
|
|
|
pipeline {
|
|
agent any
|
|
|
|
stages {
|
|
stage('Update from git') {
|
|
steps {
|
|
script {
|
|
disableSafeDirCheck()
|
|
dir("/_sd_/_programs_") {
|
|
git_take(projects, git_remote)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|