You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.5 KiB
69 lines
2.5 KiB
#!groovy
|
|
|
|
library identifier: '3scale-toolbox-jenkins@add-features',
|
|
retriever: modernSCM([$class: 'GitSCMSource',
|
|
remote: 'https://github.com/rh-integration/3scale-toolbox-jenkins.git'
|
|
traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait']]])
|
|
|
|
def service = null
|
|
def testApplicationCredentials = null
|
|
|
|
node() {
|
|
stage('Checkout Source') {
|
|
checkout scm
|
|
}
|
|
|
|
stage("Prepare") {
|
|
service = toolbox.prepareThreescaleService(
|
|
openapi: [filename: "testcase-01/swagger.json"],
|
|
environment: [ baseSystemName: toolbox.generateRandomBaseSystemName(),
|
|
privateBaseUrl: params.PRIVATE_BASE_URL ],
|
|
toolbox: [openshiftProject: params.NAMESPACE, destination: params.TARGET_INSTANCE, secretName: params.SECRET_NAME],
|
|
service: [:],
|
|
applicationPlans: [
|
|
[ systemName: "test", name: "Test", defaultPlan: true, published: true ],
|
|
[ systemName: "silver", name: "Silver" ],
|
|
[ systemName: "gold", name: "Gold" ],
|
|
]
|
|
)
|
|
|
|
echo "toolbox version = " + service.toolbox.getToolboxVersion()
|
|
}
|
|
|
|
stage("Import OpenAPI") {
|
|
service.importOpenAPI()
|
|
echo "Service with system_name ${service.environment.targetSystemName} created !"
|
|
}
|
|
|
|
stage("Create an Application Plan") {
|
|
service.applyApplicationPlans()
|
|
}
|
|
|
|
stage("Create an Application") {
|
|
def testApplication = [
|
|
name: "my-test-app",
|
|
description: "This is used for tests",
|
|
applicationPlan: "test",
|
|
accountId: params.DEVELOPER_ACCOUNT_ID
|
|
]
|
|
|
|
testApplicationCredentials = toolbox.getDefaultApplicationCredentials(service, testApplication.name)
|
|
service.applyApplication(testApplication + testApplicationCredentials)
|
|
}
|
|
|
|
stage("Run integration tests") {
|
|
// 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 = service.readProxy("sandbox")
|
|
sh """set -e +x
|
|
curl -f -w "ListBeers: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/beer -H 'api-key: ${testApplicationCredentials.userKey}'
|
|
curl -f -w "GetBeer: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/beer/Weissbier -H 'api-key: ${testApplicationCredentials.userKey}'
|
|
curl -f -w "GetBeer: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/beer/findByStatus/available -H 'api-key: ${testApplicationCredentials.userKey}'
|
|
"""
|
|
}
|
|
|
|
stage("Promote to production") {
|
|
service.promoteToProduction()
|
|
}
|
|
|
|
}
|
|
|