From 4b44bc7a1acc8285aced0030127bd461c3dde7d1 Mon Sep 17 00:00:00 2001 From: Alexander Semenets Date: Sat, 22 Dec 2018 21:58:48 +0300 Subject: [PATCH] [#682] move condition to bash --- deploy/create-cluster.Jenkinsfile | 3 +-- deploy/legionPipeline.groovy | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/deploy/create-cluster.Jenkinsfile b/deploy/create-cluster.Jenkinsfile index 08f3c594c..623de9089 100644 --- a/deploy/create-cluster.Jenkinsfile +++ b/deploy/create-cluster.Jenkinsfile @@ -30,8 +30,7 @@ pipeline { stage('Create Kubernetes Cluster') { steps { script { - mounts = legion.ansibleContainerMount() - legion.createCluster(mounts) + legion.createCluster() } } } diff --git a/deploy/legionPipeline.groovy b/deploy/legionPipeline.groovy index c7a1ea7f6..362301490 100644 --- a/deploy/legionPipeline.groovy +++ b/deploy/legionPipeline.groovy @@ -20,16 +20,25 @@ def ansibleContainerMount() { ("${param_debug_run}" == "true" ) ? "${WORKSPACE}/deploy:/opt/legion/deploy" : "${WORKSPACE}/deploy/profiles:/opt/legion/deploy/profiles" } -def createCluster(mounts) { - print(mounts) +def createCluster() { withCredentials([ file(credentialsId: "vault-${env.param_profile}", variable: 'vault')]) { withAWS(credentials: 'kops') { wrap([$class: 'AnsiColorBuildWrapper', colorMapName: "xterm"]) { - docker.image("${env.param_docker_repo}/k8s-ansible:${env.param_legion_version}").inside("-e HOME=/opt/deploy/legion -v ${mounts} -v /etc/ssl:/etc/ssl -u root") { + docker.image("${env.param_docker_repo}/k8s-ansible:${env.param_legion_version}").inside("-e HOME=/opt/deploy/legion -v ${WORKSPACE}/deploy/profiles:/opt/legion/deploy/profiles -v /etc/ssl:/etc/ssl -u root") { stage('Create cluster') { sh """ - cd /opt/legion/deploy/ansible && ansible-playbook create-cluster.yml \ + set -e + + # Run ansible from workspace for debug or from baked code inside container + if [ ${param_debug_run} == "true" ]; then + cd "${WORKSPACE}/deploy/ansible + else + cd /opt/legion/deploy/ansible + fi + + pwd + #ansible-playbook create-cluster.yml \ --vault-password-file=${vault} \ --extra-vars "profile=${env.param_profile} \ legion_version=${env.param_legion_version} \