0

I know it's possible to have that when using Jenkins inside of Openshift, but when using pure build images it seems full CI/CD seems to be missing.

Our perfect scenario for each push to 'master' branch would be:

  • build app
  • run unit tests
  • notify team if failed to build
  • deploy image
  • notify if failed to start

Simple Openshift build setup only includes bold items.

Can we have full CI/CD inside of Openshift? Or should we do checks outside? Also notifications on failures are still missing in Openshift as far as I know.

Karolis
  • 157
  • 7
  • 1
    The intended method of performing these tasks is to use Jenkins (https://docs.okd.io/latest/using_images/other_images/jenkins.html), which is automatically available to the cluster, and you can add things like OpenShift Pipelines with Jenkins to show these things as part of the Web Console (https://docs.okd.io/latest/dev_guide/dev_tutorials/openshift_pipeline.html) – Will Gordon Nov 09 '18 at 22:50

1 Answers1

1

Personally, I think you had better use the OpenShift Pipeline Jebkins Plugin for your use. It can be implemented your own CI/CD using various ways, so it's a just sample. Maybe you would undergo trial and error for finding your own CI/CD configurations.

For example, simple build and deploy description using OpenShift Pipeline Jenkins Plugin. For more details, refer here And post notification for the job result is configured using 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

I hope it help you.

Daein Park
  • 4,393
  • 2
  • 12
  • 21