如何在openshift中获得完整的CI / CD?

问题描述 投票:0回答:1

我知道在Openshift中使用Jenkins时可以使用它,但是当使用纯构建映像时,似乎完整的CI / CD似乎缺失了。

每次推送到“主”分支的完美场景是:

  • 构建应用程序
  • 运行单元测试
  • 如果构建失败,请通知团队
  • 部署图像
  • 如果启动失败则通知

简单的Openshift构建设置仅包括粗体项。

我们可以在Openshift内部拥有完整的CI / CD吗?或者我们应该在外面做检查吗?据我所知,在Openshift中仍然没有关于故障的通知。

continuous-integration openshift continuous-delivery
1个回答
1
投票

就个人而言,我认为你最好使用OpenShift Pipeline Jebkins Plugin供你使用。它可以使用各种方式实现您自己的CI/CD,因此它只是一个样本。也许你会因为找到自己的CI/CD配置而经历反复试验。

例如,使用OpenShift Pipeline Jenkins Plugin进行简单的构建和部署描述。有关更多详细信息,请参阅here并使用Cleaning up and notifications配置作业结果的发布通知。

apiVersion: v1
kind: BuildConfig
metadata:
  labels:
    name: your-pipeline
  name: your-pipeline
spec:
  runPolicy: Serial
  strategy:
    jenkinsPipelineStrategy:
      jenkinsfile: |-
        node(''){
          stage('some unit tests') {
            sh 'git clone https://github.com/yourproject/yourrepo'
            sh 'python -m unittest tests/unittest_start_and_result_mailing.py'
          }
          stage('Build using your-yourconfig'){
              openshiftBuild(namespace: 'your-project', bldCfg: 'your-buildconfig', showBuildLogs: 'true')
          }
          stage('Deployment using your-deploymentconfig'){
              openshiftDeploy(namespace: 'your-project', depCfg: 'your-deploymentconfig')
          }
          stage('Verify Deployment status'){
              openshiftVerifyDeployment(namespace: 'your-project', depCfg: 'your-deploymentconfig', verifyReplicaCount: 'true')
          }
        }
        post {
          always {
            echo 'One way or another, I have finished'
            deleteDir() /* clean up our workspace */
          }
          success {
            echo 'I succeeeded!'
          }
          unstable {
            echo 'I am unstable :/'
          }
          failure {
            echo 'I failed :('
          }
          changed {
            echo 'Things were different before...'
          }
        }
    type: JenkinsPipeline
  triggers:
  - github:
      secret: gitsecret
    type: GitHub
  - generic:
      secret: genericsecret
    type: Generic

我希望它对你有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.