Newer
Older
openstack-caracal-ipv4 / clientdocs / scripts / Jenkinsfile.example
// Jenkinsfile.example -- declarative pipeline skeleton for your Omega Cloud
// environment, following the CI/Automation Integration Guide.
//
// What: smoke test -> the guide's worked sequence (via acceptance-run.sh)
//       -> an always-runs cleanup, all authenticated with your application
//       credential injected from the Jenkins credential store.
// Setup (once, in Manage Jenkins > Credentials): add a "Username with
//       password" credential with id 'omega-cloud-app-credential', where
//       username = the application credential id and password = its secret,
//       both from the credential file delivered to your custodians. Never
//       put them in this file or any repository.
// Notes: adjust the script paths to wherever you keep the delivered starter
//       kit scripts in your repository. Keep the delivered CA bundle in your
//       repository or agent image and point OS_CACERT at it -- do not
//       disable certificate verification instead.

pipeline {
    agent any

    options {
        timestamps()
        // Load balancers take minutes; the acceptance sequence is not fast.
        timeout(time: 60, unit: 'MINUTES')
    }

    environment {
        // credentials() injects OMEGA_USR (the id) and OMEGA_PSW (the
        // secret) and masks them in the build log.
        OMEGA = credentials('omega-cloud-app-credential')

        // Environment-variable auth form from the integration guide.
        OS_AUTH_TYPE            = 'v3applicationcredential'
        OS_AUTH_URL             = 'FILL-ME: auth url from your Handover Pack'
        OS_IDENTITY_API_VERSION = '3'
        OS_REGION_NAME          = 'FILL-ME: region from your Handover Pack'
        OS_CACERT               = "${WORKSPACE}/FILL-ME-delivered-ca-bundle.pem"
        OS_APPLICATION_CREDENTIAL_ID     = "${OMEGA_USR}"
        OS_APPLICATION_CREDENTIAL_SECRET = "${OMEGA_PSW}"
    }

    stages {
        stage('Smoke test') {
            steps {
                // Token, catalog, quota -- fail fast before building anything.
                sh 'bash clientdocs-starter-kit/smoke-test.sh'
            }
        }

        stage('Worked sequence') {
            steps {
                // The guide section-7 sequence with automatic teardown.
                // Replace this with your own deployment steps once you have
                // them; keep a trimmed version as a recurring smoke test.
                sh 'bash clientdocs-starter-kit/acceptance-run.sh'
            }
        }
    }

    post {
        // Cleanup runs on success, failure, and abort alike, so a broken
        // build cannot leak quota. This deletes THIS kit's leftovers
        // (ci-accept-*) of any age; run the sweep with its defaults
        // (--prefix ci- --hours 24) as a separate scheduled job to catch
        // everything else your pipelines leak.
        always {
            sh 'bash clientdocs-starter-kit/ci-cleanup-sweep.sh --prefix ci-accept- --hours 0 --apply'
        }
    }
}