From aa47dfbb6a827ab8ad428f94f514cf7ad8374bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Thu, 28 Feb 2019 20:47:40 +0100 Subject: [PATCH] update jenkins pipeline --- support/jenkins/Jenkinsfile | 56 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/support/jenkins/Jenkinsfile b/support/jenkins/Jenkinsfile index ab4bb25..d150689 100644 --- a/support/jenkins/Jenkinsfile +++ b/support/jenkins/Jenkinsfile @@ -7,43 +7,45 @@ */ pipeline { - agent any + agent { label 'ansible' } parameters { credentials(name: 'THREESCALE_CICD_ACCESS_TOKEN', description: 'The 3scale Access Token', credentialType: "Secret text", required: true) credentials(name: 'THREESCALE_CICD_SSO_ISSUER_ENDPOINT', description: 'The SSO Issuer Endpoint when deploying an API with OpenID Connect', credentialType: "Secret text", required: false) - stringParam(name: 'THREESCALE_PORTAL_HOSTNAME', description: 'The 3scale Admin Portal hostname', required: true) - stringParam(name: 'GIT_REPOSITORY', description: 'The GIT repository to checkout, containing the OpenAPI Specifications', required: true) - stringParam(name: 'GIT_BRANCH', description: 'The GIT branch or tag to checkout, containing the OpenAPI Specifications', defaultValue: 'master', required: true) - stringParam(name: 'OPENAPI_FILE', description: 'The path to the OpenAPI Specification within the GIT Repository', required: true) - stringParam(name: 'THREESCALE_CICD_PRIVATE_BASE_URL', description: 'The 3scale private base URL', required: false) + string(name: 'THREESCALE_PORTAL_HOSTNAME', description: 'The 3scale Admin Portal hostname') + string(name: 'GIT_REPOSITORY', description: 'The GIT repository to checkout, containing the OpenAPI Specifications') + string(name: 'GIT_BRANCH', description: 'The GIT branch or tag to checkout, containing the OpenAPI Specifications', defaultValue: 'master') + string(name: 'OPENAPI_FILE', description: 'The path to the OpenAPI Specification within the GIT Repository') + string(name: 'THREESCALE_CICD_PRIVATE_BASE_URL', description: 'The 3scale private base URL') } - node("ansible") { - sh 'ansible --version' - + stages { stage("GIT Checkout") { - // Checkout the GIT repository containing the Ansible Playbook - checkout scm - - // Checkout the GIT repository containing the OpenAPI Specification to provision - checkout([ $class: 'GitSCM', - branches: [[name: '*/'+params.GIT_BRANCH]], - doGenerateSubmoduleConfigurations: false, - extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'support/jenkins/api']], - submoduleCfg: [], - userRemoteConfigs: [[url: params.GIT_REPOSITORY]]]) + steps { + // Checkout the GIT repository containing the Ansible Playbook + checkout scm + + // Checkout the GIT repository containing the OpenAPI Specification to provision + checkout([ $class: 'GitSCM', + branches: [[name: '*/'+params.GIT_BRANCH]], + doGenerateSubmoduleConfigurations: false, + extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'support/jenkins/api']], + submoduleCfg: [], + userRemoteConfigs: [[url: params.GIT_REPOSITORY]]]) + } } stage("Deploy an API to 3scale") { - ansiColor('xterm') { - withCredentials([ string(credentialsId: params.THREESCALE_CICD_ACCESS_TOKEN, variable: 'THREESCALE_CICD_ACCESS_TOKEN'), - string(credentialsId: params.THREESCALE_CICD_SSO_ISSUER_ENDPOINT, variable: 'THREESCALE_CICD_SSO_ISSUER_ENDPOINT')]) { - - ansiblePlaybook(playbook: 'support/jenkins/deploy-api.yaml', - extraVars: [ threescale_cicd_openapi_file: 'api/' + params.OPENAPI_FILE ], - /* extras: '-v', // verbose mode */ - colorized: true) + steps { + ansiColor('xterm') { + withCredentials([ string(credentialsId: params.THREESCALE_CICD_ACCESS_TOKEN, variable: 'THREESCALE_CICD_ACCESS_TOKEN'), + string(credentialsId: params.THREESCALE_CICD_SSO_ISSUER_ENDPOINT, variable: 'THREESCALE_CICD_SSO_ISSUER_ENDPOINT')]) { + + ansiblePlaybook(playbook: 'support/jenkins/deploy-api.yaml', + extraVars: [ threescale_cicd_openapi_file: 'api/' + params.OPENAPI_FILE ], + /* extras: '-v', // verbose mode */ + colorized: true) + } } } }