ниже мой сценарий.Идея состоит в том, чтобы создавать проекты на основе шаблонного проекта, чтобы разработчику не нужно было повторять эту работу каждый раз, когда появляется новый проект ... шаблонный проект будет иметь все необходимые сценарии для запуска CI, автоматического выпуска и развертывания автоматически...
node {
try {
stage('Clean Up') {
deleteDir()
stage('Verify New Github Repo Exists') {
sh 'git ls-remote git@github.com:account/${githubProject}.git' // check if repo exist
stage('Clone Github Repo') {
// clone into directory and cd
sh 'git clone git@github.com:account/${githubProject}.git .'
sh 'git remote -v'
sh 'ls -lash'
stage('Merge Template Into Project') {
// add the template into the project
sh 'git remote add template git@github.com:account/${appType}-jenkins-ci-template.git'
sh 'git remote -v' // this shows both origin and template repos
sh 'git fetch --all'
sh 'git merge template/master' // able to merge origin's master with template's
sh 'ls -lash'
sh 'git log --graph --abbrev-commit --max-count=10'
sh 'git push -u origin master' // when the code get here, it fails to push, ends up with ERROR: Repository not found.
// do the work to replace all __APP_NAME__ with the actual app name/service
// commit and push to master
stage('Configure Project Properties') {
// clone and copy property files from template project
// do the work to replace all __APP_NAME__ with the actual app name/service
// commit and push to master
stage('Wrap Up') {
// creating jenkins jobs will continue to be manual
}
}
}
}
}
}
} catch (e) {
//notifyFailure(e, "Script failure!")
currentBuild.result = "FAILURE"
}
}