4 changed files with 155 additions and 18 deletions
@ -0,0 +1,68 @@ |
|||||
|
#!groovy |
||||
|
|
||||
|
library identifier: '3scale-toolbox-jenkins@add-new-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 |
||||
|
|
||||
|
node() { |
||||
|
stage('Checkout Source') { |
||||
|
checkout scm |
||||
|
} |
||||
|
|
||||
|
stage("Prepare") { |
||||
|
service = toolbox.prepareThreescaleService( |
||||
|
openapi: [filename: "testcase-02/swagger.json"], |
||||
|
environment: [ baseSystemName: toolbox.generateRandomBaseSystemName(), |
||||
|
privateBaseUrl: params.PRIVATE_BASE_URL, |
||||
|
privateBasePath: "/api", |
||||
|
publicStagingWildcardDomain: params.PUBLIC_STAGING_WILDCARD_DOMAIN, |
||||
|
publicProductionWildcardDomain: params.PUBLIC_PRODUCTION_WILDCARD_DOMAIN ], |
||||
|
toolbox: [openshiftProject: params.NAMESPACE, destination: params.TARGET_INSTANCE, secretName: params.SECRET_NAME], |
||||
|
service: [:], |
||||
|
applications: [ |
||||
|
[ name: "my-test-app", description: "This is used for tests", plan: "test", account: params.DEVELOPER_ACCOUNT_ID ] |
||||
|
], |
||||
|
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") { |
||||
|
service.applyApplication() |
||||
|
} |
||||
|
|
||||
|
stage("Run integration tests") { |
||||
|
// The staging and production base URLs are computed by the shared library |
||||
|
def proxy = [ |
||||
|
endpoint: service.environment.productionPublicBaseURL, |
||||
|
sandbox_endpoint: service.environment.stagingPublicBaseURL |
||||
|
] |
||||
|
sh """set -e +x |
||||
|
curl -f -k -w "ListBeers: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/beer |
||||
|
curl -f -k -w "GetBeer: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/beer/Weissbier |
||||
|
curl -f -k -w "FindBeersByStatus: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/beer/findByStatus/available |
||||
|
""" |
||||
|
} |
||||
|
|
||||
|
stage("Promote to production") { |
||||
|
service.promoteToProduction() |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
apiVersion: v1 |
||||
|
kind: Template |
||||
|
metadata: |
||||
|
name: testcase-02 |
||||
|
objects: |
||||
|
- kind: "BuildConfig" |
||||
|
apiVersion: "v1" |
||||
|
metadata: |
||||
|
name: "testcase-02" |
||||
|
namespace: ${NAMESPACE} |
||||
|
spec: |
||||
|
source: |
||||
|
git: |
||||
|
uri: ${GIT_REPO} |
||||
|
strategy: |
||||
|
type: "JenkinsPipeline" |
||||
|
jenkinsPipelineStrategy: |
||||
|
jenkinsfilePath: testcase-02/Jenkinsfile |
||||
|
env: |
||||
|
- name: SECRET_NAME |
||||
|
value: ${SECRET_NAME} |
||||
|
- name: NAMESPACE |
||||
|
value: ${NAMESPACE} |
||||
|
- name: TARGET_INSTANCE |
||||
|
value: ${TARGET_INSTANCE} |
||||
|
- name: PUBLIC_STAGING_WILDCARD_DOMAIN |
||||
|
value: ${PUBLIC_STAGING_WILDCARD_DOMAIN} |
||||
|
- name: PUBLIC_PRODUCTION_WILDCARD_DOMAIN |
||||
|
value: ${PUBLIC_PRODUCTION_WILDCARD_DOMAIN} |
||||
|
- name: DEVELOPER_ACCOUNT_ID |
||||
|
value: ${DEVELOPER_ACCOUNT_ID} |
||||
|
- name: PRIVATE_BASE_URL |
||||
|
value: ${PRIVATE_BASE_URL} |
||||
|
parameters: |
||||
|
- name: SECRET_NAME |
||||
|
value: 3scale-toolbox |
||||
|
- name: NAMESPACE |
||||
|
value: api-lifecycle |
||||
|
- name: TARGET_INSTANCE |
||||
|
required: true |
||||
|
- name: GIT_REPO |
||||
|
value: https://github.com/nmasse-itix/API-Lifecycle-Mockup.git |
||||
|
- name: PUBLIC_STAGING_WILDCARD_DOMAIN |
||||
|
required: true |
||||
|
- name: PUBLIC_PRODUCTION_WILDCARD_DOMAIN |
||||
|
required: true |
||||
|
- name: DEVELOPER_ACCOUNT_ID |
||||
|
required: true |
||||
|
- name: PRIVATE_BASE_URL |
||||
|
required: true |
||||
Loading…
Reference in new issue