如何使用 Jenkins 管道将代码合并回 Github

时间:2021-03-06 20:55:46

标签: git jenkins github jenkins-pipeline

我正在尝试使用 Jenkins 管道将代码合并回 github。我现在拥有的脚本抱怨它不是 git repo。

pipeline {
    agent { label 'docker-agent' }
    stages {
        stage('Checkout Git'){
            steps {
                dir('repo1') {
                    git credentialsId: 'xxxxx-xxx-xxx-xxx-xxxx',
                    branch: "master",
                    url: 'https://github.com/repo/repo1.git'
                }
                dir('repo2') {
                    git credentialsId: 'xxxxx-xxx-xxx-xxx-xxxx',
                    branch: "master",
                    url: 'https://github.com/repo/repo2.git'
                }
            }
        }
        
        stage('Environment Setup'){
            steps {
                sh 'pip3 install --user -r superloop/requirements.txt'
            }
        }
        
        stage('Run program'){
            steps {
                sh 'python3 main.py'
            }
        }
        
        stage('Prepare files to sync'){
            steps {
                dir('repo2') {
                    sh 'git add .'
                    sh 'git commit -m "Updates"'
                    sh 'git push origin master'
            }
        }
    }
}

来自控制台输出的错误信息:

+ git add .
fatal: Not a git repository (or any of the parent directories): .git

如何将代码从管道提交/合并回存储库?

0 个答案:

没有答案