Jenkins声明式管道-SCM

时间:2019-01-02 19:38:30

标签: jenkins jenkins-declarative-pipeline

我正在学习一些詹金斯教程。我阅读的示例代码是

 pipeline {
    agent none
    stages {
        stage('Build') {
            agent {
                docker {
                    image 'python:2-alpine'
                }
            }
            steps {
                sh 'python -m py_compile sources/add2vals.py sources/calc.py'
            }
        }
        stage('Test') {
            agent {
                docker {
                    image 'qnib/pytest'
                }
            }
            steps {
                sh 'py.test --verbose --junit-xml test-reports/results.xml sources/test_calc.py'
            }
            post {
                always {
                    junit 'test-reports/results.xml'
                }
            }
        }
        stage('Deliver') { 
            agent {
                docker {
                    image 'cdrx/pyinstaller-linux:python2' 
                }
            }
            steps {
                sh 'pyinstaller --onefile sources/add2vals.py' 
            }
            post {
                success {
                    archiveArtifacts 'dist/add2vals' 
                }
            }
        }
    }
}

因此,基本上有三个步骤BuildTestDeliver。它们都使用不同的图像来生成不同的容器。但是,此Jenkins作业已配置为使用Git作为SCM

因此,如果运行此Jenkins构建,则表示该项目构建在第一个容器上。然后第二阶段是在另一个容器上测试项目,然后在第三个容器上进行交付。 Jenkins的工作如何确保这三个步骤按顺序对代码执行。

根据我的理解,每个阶段都需要执行git clone/git pull,并且在阶段结束之前,需要git push

如果通过詹金斯(Jenkins)将SCM IS 配置为使用Git,我们是否需要包括詹金斯(Jenkins)的git clone/git pull', as well as 'git push' in the corresponding shell scripts(under步骤, or it it already taken into consideration by the SCM`功能?

谢谢

1 个答案:

答案 0 :(得分:0)

在这种情况下,必须确保QA环境中的二进制文件必须与UAT环境中然后在生产环境中的二进制文件相同。 为此,您必须使用工件存储库或注册表(Artifactory,Nexus,Docker注册表等)将工件升级到生产环境。 参见此link,并了解其在管道中的完成方式。

相关问题