Browse Source

update jenkins pipeline

pull/50/head
Nicolas Massé 7 years ago
parent
commit
aa47dfbb6a
  1. 56
      support/jenkins/Jenkinsfile

56
support/jenkins/Jenkinsfile

@ -7,43 +7,45 @@
*/ */
pipeline { pipeline {
agent any agent { label 'ansible' }
parameters { parameters {
credentials(name: 'THREESCALE_CICD_ACCESS_TOKEN', description: 'The 3scale Access Token', credentialType: "Secret text", required: true) 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) 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) string(name: 'THREESCALE_PORTAL_HOSTNAME', description: 'The 3scale Admin Portal hostname')
stringParam(name: 'GIT_REPOSITORY', description: 'The GIT repository to checkout, containing the OpenAPI Specifications', required: true) string(name: 'GIT_REPOSITORY', description: 'The GIT repository to checkout, containing the OpenAPI Specifications')
stringParam(name: 'GIT_BRANCH', description: 'The GIT branch or tag to checkout, containing the OpenAPI Specifications', defaultValue: 'master', required: true) string(name: 'GIT_BRANCH', description: 'The GIT branch or tag to checkout, containing the OpenAPI Specifications', defaultValue: 'master')
stringParam(name: 'OPENAPI_FILE', description: 'The path to the OpenAPI Specification within the GIT Repository', required: true) string(name: 'OPENAPI_FILE', description: 'The path to the OpenAPI Specification within the GIT Repository')
stringParam(name: 'THREESCALE_CICD_PRIVATE_BASE_URL', description: 'The 3scale private base URL', required: false) string(name: 'THREESCALE_CICD_PRIVATE_BASE_URL', description: 'The 3scale private base URL')
} }
node("ansible") { stages {
sh 'ansible --version'
stage("GIT Checkout") { stage("GIT Checkout") {
// Checkout the GIT repository containing the Ansible Playbook steps {
checkout scm // Checkout the GIT repository containing the Ansible Playbook
checkout scm
// Checkout the GIT repository containing the OpenAPI Specification to provision
checkout([ $class: 'GitSCM', // Checkout the GIT repository containing the OpenAPI Specification to provision
branches: [[name: '*/'+params.GIT_BRANCH]], checkout([ $class: 'GitSCM',
doGenerateSubmoduleConfigurations: false, branches: [[name: '*/'+params.GIT_BRANCH]],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'support/jenkins/api']], doGenerateSubmoduleConfigurations: false,
submoduleCfg: [], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'support/jenkins/api']],
userRemoteConfigs: [[url: params.GIT_REPOSITORY]]]) submoduleCfg: [],
userRemoteConfigs: [[url: params.GIT_REPOSITORY]]])
}
} }
stage("Deploy an API to 3scale") { stage("Deploy an API to 3scale") {
ansiColor('xterm') { steps {
withCredentials([ string(credentialsId: params.THREESCALE_CICD_ACCESS_TOKEN, variable: 'THREESCALE_CICD_ACCESS_TOKEN'), ansiColor('xterm') {
string(credentialsId: params.THREESCALE_CICD_SSO_ISSUER_ENDPOINT, variable: 'THREESCALE_CICD_SSO_ISSUER_ENDPOINT')]) { 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 ], ansiblePlaybook(playbook: 'support/jenkins/deploy-api.yaml',
/* extras: '-v', // verbose mode */ extraVars: [ threescale_cicd_openapi_file: 'api/' + params.OPENAPI_FILE ],
colorized: true) /* extras: '-v', // verbose mode */
colorized: true)
}
} }
} }
} }

Loading…
Cancel
Save