Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save darinpope/c724e7322850b5486594c061f602be6a to your computer and use it in GitHub Desktop.
Save darinpope/c724e7322850b5486594c061f602be6a to your computer and use it in GitHub Desktop.

Gist for https://youtu.be/Mk_dbU1v8S0

Documentation

Jenkinsfile

pipeline {
    agent any
    environment {
        KALIX_TOKEN=credentials('kalix-token')
        KALIX_PROJECT='4d0b22b2-1115-403a-bf30-153a415e961c'
        SERVICE_NAME='shopping-cart'
    }
    stages {
        stage('Version') {
            steps {
                sh 'kalix version'
            }
        }
        stage('force logout') {
            steps {
                sh 'kalix auth logout'
            }
        }
        stage('set token') {
            steps {
                sh 'kalix config set refresh-token $KALIX_TOKEN'
            }
        }
        stage('set project') {
            steps {
                sh 'kalix config set project $KALIX_PROJECT'
            }
        }
        stage('deploy') {
            steps {
                sh 'kalix services deploy $SERVICE_NAME gcr.io/kalix-public/samples-java-value-entity-shopping-cart:0.0.2'
            }
        }
        stage('wait until deployed') {
            steps {
                timeout(5) {
                    waitUntil(initialRecurrencePeriod: 30000) {
                        script {
                            def status = sh(returnStatus: true, script:'kalix services list | grep $SERVICE_NAME | grep Ready');
                            return (status == 0);
                        }
                    }
                }
            }
        }
        stage('sleep') {
            steps {
                sleep(5)
            }
        }
        stage('expose') {
            when {
                expression {
                    return sh(returnStatus:true, script:'kalix routes get $SERVICE_NAME') == 1
                }
            }
            steps {
                sh 'kalix services expose $SERVICE_NAME'
            }
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment