Merge "Improved insufficient permissions handling in aptly promote pipeline"
diff --git a/build-mirror-image.groovy b/build-mirror-image.groovy
index 0700d60..4c42b3e 100644
--- a/build-mirror-image.groovy
+++ b/build-mirror-image.groovy
@@ -25,13 +25,13 @@
def git = new com.mirantis.mk.Git()
def date = new Date()
def dateTime = date.format("ddMMyyyy-HHmmss")
-def openstackServer = ""
def rcFile = ""
def openstackEnv = ""
def uploadImageStatus = ""
def uploadMd5Status = ""
-ArrayList extra_vars = job_env.get('EXTRA_VARIABLES', '').readLines()
-def IMAGE_NAME = job_env.get('IMAGE_NAME', "packer-image") + "-" + dateTime
+def creds
+ArrayList extra_vars = EXTRA_VARIABLES.readLines()
+IMAGE_NAME = IMAGE_NAME + "-" + dateTime
timeout(time: 8, unit: 'HOURS') {
node("python&&disk-xl") {
@@ -40,7 +40,6 @@
openstackEnv = "${workspace}/venv"
stage("Prepare env") {
- checkout scm
if (!fileExists("${workspace}/tmp")) {
sh "mkdir -p ${workspace}/tmp"
}
@@ -64,27 +63,28 @@
openstack.setupOpenstackVirtualenv(openstackEnv, OS_VERSION)
git.checkoutGitRepository(PACKER_TEMPLATES_REPO_NAME, PACKER_TEMPLATES_REPO_URL, PACKER_TEMPLATES_BRANCH)
+ creds = common.getPasswordCredentials(OS_CREDENTIALS_ID)
}
stage("Build Instance") {
- rcFile = openstack.createOpenstackEnv(OS_URL, OS_CREDENTIALS_ID, OS_PROJECT, "default", "", "default", "2", "")
dir("${workspace}/${PACKER_TEMPLATES_REPO_NAME}/${BUILD_OS}/") {
withEnv(extra_vars + ["PATH=${env.PATH}:${workspace}/bin",
"PACKER_LOG_PATH=${workspace}/packer.log",
"PACKER_LOG=1",
- "TMPDIR=${workspace}/tmp"]) {
+ "TMPDIR=${workspace}/tmp",
+ "IMAGE_NAME=${IMAGE_NAME}",
+ "OS_USERNAME=${creds.username}",
+ "OS_PASSWORD=${creds.password.toString()}"]) {
if (PACKER_DEBUG.toBoolean()) {
PACKER_ARGS = "${PACKER_ARGS} -debug"
}
- sh "source extra.vars ; packer build -only=${BUILD_ONLY} ${PACKER_ARGS} -parallel=false template.json"
+ sh "packer build -only=${BUILD_ONLY} ${PACKER_ARGS} -parallel=false template.json"
def packerStatus = sh(script: "grep \"Some builds didn't complete successfully and had errors\" ${PACKER_LOG_PATH}", returnStatus: true)
// grep returns 0 if find something
if (packerStatus != 0) {
- if (buildTypes.contains("openstack")) {
- common.infoMsg("Openstack instance complete")
- }
+ common.infoMsg("Openstack instance complete")
} else {
throw new Exception("Packer build failed")
}
@@ -94,6 +94,8 @@
stage("Publish image") {
common.infoMsg("Saving image ${IMAGE_NAME}")
+ rcFile = openstack.createOpenstackEnv(workspace, OS_URL, OS_CREDENTIALS_ID, OS_PROJECT, "default", "", "default", "2", "")
+
common.retry(3, 5) {
openstack.runOpenstackCommand("openstack image save --file ${IMAGE_NAME}.qcow2 ${IMAGE_NAME}", rcFile, openstackEnv)
}
@@ -122,25 +124,16 @@
throw e
} finally {
if (CLEANUP_AFTER) {
- stage("Cleanup") {
- if (openstackServer != "") {
- openstack.runOpenstackCommand("openstack server delete ${IMAGE_NAME}", rcFile, openstackEnv)
- openstack.runOpenstackCommand("openstack image delete ${IMAGE_NAME}", rcFile, openstackEnv)
- }
dir(workspace) {
sh "rm -rf ./*"
}
- }
-
} else {
common.infoMsg("Env has not been cleanup!")
common.infoMsg("Packer private key:")
dir("${workspace}/${PACKER_TEMPLATES_REPO_NAME}/${BUILD_OS}/") {
sh "cat os_${BUILD_OS}.pem"
}
-
}
}
-
}
}
diff --git a/cloud-deploy-pipeline.groovy b/cloud-deploy-pipeline.groovy
index ad46e2f..a37a655 100644
--- a/cloud-deploy-pipeline.groovy
+++ b/cloud-deploy-pipeline.groovy
@@ -18,6 +18,7 @@
* STACK_CLEANUP_JOB Name of job for deleting stack
*
* STACK_COMPUTE_COUNT Number of compute nodes to launch
+ * STACK_CLUSTER_NAME The name of cluster model to use
* STATIC_MGMT_NETWORK Check if model contains static IP address definitions for all nodes
*
* AWS_STACK_REGION CloudFormation AWS region
@@ -194,6 +195,12 @@
envParams.put('cfg_extra_formulas', EXTRA_FORMULAS)
}
+ // add cluster name if specified
+ if (common.validInputParam('STACK_CLUSTER_NAME')) {
+ common.infoMsg("Setting cluster_name to ${STACK_CLUSTER_NAME}")
+ envParams.put('cluster_name', STACK_CLUSTER_NAME)
+ }
+
openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, venv)
}