Почему мой сценарий jenkins, похоже, «забывает о происхождении», хотя он извлекает из него код? - PullRequest
0 голосов
/ 25 марта 2019

ниже мой сценарий.Идея состоит в том, чтобы создавать проекты на основе шаблонного проекта, чтобы разработчику не нужно было повторять эту работу каждый раз, когда появляется новый проект ... шаблонный проект будет иметь все необходимые сценарии для запуска 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"
}

}

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...