#!groovy library identifier: '3scale-toolbox-jenkins@master', retriever: modernSCM([$class: 'GitSCMSource', remote: 'https://github.com/nmasse-itix/3scale-toolbox-jenkins.git']) def toolboxConfig = [ "secretName": params.SECRET_NAME ] def baseSystemName = toolbox.generateRandomBaseSystemName() def targetSystemName = null node() { stage('Checkout Source') { //git url: "https://github.com/nmasse-itix/API-Lifecycle-Mockup.git" checkout scm } stage("Get toolbox version") { openshift.withCluster() { openshift.withProject(params.NAMESPACE) { echo "toolbox version = " + toolbox.getToolboxVersion(openshift: openshift) } } } stage("Import OpenAPI") { openshift.withCluster() { openshift.withProject(params.NAMESPACE) { // Here we would need to pass the public staging/prod url when using // APIcast Self-Managed // See https://issues.jboss.org/browse/THREESCALE-2607 targetSystemName = toolbox.importOpenAPI(openshift: openshift, destination: params.TARGET_INSTANCE, toolboxConfig: toolboxConfig, oasFile: "testcase-01/swagger.json", baseSystemName: baseSystemName) echo "Service with system_name ${targetSystemName} created !" } } } stage("Create an Application Plan") { openshift.withCluster() { openshift.withProject(params.NAMESPACE) { toolbox.applyApplicationPlan(openshift: openshift, destination: params.TARGET_INSTANCE, serviceSystemName: targetSystemName, planSystemName: "test_plan", planDisplayName: "Test Plan", toolboxConfig: toolboxConfig) } } } stage("Create an Application") { openshift.withCluster() { openshift.withProject(params.NAMESPACE) { toolbox.createApplication(openshift: openshift, destination: params.TARGET_INSTANCE, serviceSystemName: targetSystemName, planSystemName: "test_plan", applicationName: "My App", applicationDescription: "Test", toolboxConfig: toolboxConfig) } } } stage("Run integration tests") { openshift.withCluster() { openshift.withProject(params.NAMESPACE) { // To run the integration tests when using APIcast SaaS instances, we need // to fetch the proxy definition to extract the staging public url def proxy = toolbox.readProxy(openshift: openshift, destination: params.TARGET_INSTANCE, serviceSystemName: targetSystemName, environment: "sandbox", toolboxConfig: toolboxConfig) sh '''set -xe curl ${proxy.sandbox_endpoint}/beers # TODO ''' } } } stage("Promote to production") { openshift.withCluster() { openshift.withProject(params.NAMESPACE) { toolbox.promoteToProduction(openshift: openshift, destination: params.TARGET_INSTANCE, serviceSystemName: targetSystemName, toolboxConfig: toolboxConfig) } } } }