Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
241 lines (230 sloc) 14.1 KB
@Library('aem-opencloud-manager') _
import cloud.aws
def configString = libraryResource 'aem_opencloud/config.json'
def config = readJSON text: configString
pipeline {
agent {
docker {
image params.JENKINS_AGENT_DOCKER_IMAGE
args params.JENKINS_AGENT_DOCKER_ARGS
}
}
environment {
TMPDIR = "/tmp/shinesolutions/aem-opencloud-manager"
AOC_CONFIG_DIR = "${env.TMPDIR}/aem-opencloud-config"
AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_EXPORT = "${env.AOC_CONFIG_DIR}/aem-aws-stack-builder/${params.AOC_CONFIG_PROFILE_AEM_AWS_STACK_BUILDER_EXPORT}/"
AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_IMPORT = "${env.AOC_CONFIG_DIR}/aem-aws-stack-builder/${params.AOC_CONFIG_PROFILE_AEM_AWS_STACK_BUILDER_IMPORT}/"
AOC_CONFIG_PROFILE_DIR_AEM_STACK_MANAGER_MESSENGER = "${env.AOC_CONFIG_DIR}/aem-stack-manager-messenger/${params.AOC_CONFIG_PROFILE_AEM_STACK_MANAGER_MESSENGER}/"
}
parameters {
string(name: 'AOC_VERSION_AEM_AWS_STACK_BUILDER', defaultValue: config.library.aem_aws_stack_builder, description: 'Version of aem-aws-stack-builder repo to archive')
string(name: 'AOC_VERSION_AEM_STACK_MANAGER_MESSENGER', defaultValue: config.library.aem_stack_manager_messenger, description: 'Version of aem-stack-manager-messenger repo')
string(name: 'AOC_DEPLOYMENT_DESCRIPTOR_URL_EXPORT_STACK', defaultValue: '', description: 'URL where deployment descriptor file is located for the export stack.')
string(name: 'AOC_DEPLOYMENT_DESCRIPTOR_URL_IMPORT_STACK', defaultValue: '', description: 'URL where deployment descriptor file is located for the import stack.')
string(name: 'PACKAGE_DATESTAMP', defaultValue: '', description: 'Package date stamp e.g. 2019.')
string(name: 'PACKAGE_GROUP', defaultValue: '', description: 'Package group name, same as defined in the export-package-descriptor.json.')
string(name: 'PACKAGE_NAME', defaultValue: '', description: 'Package name, same as defined in the export-package-descriptor.json.')
string(name: 'SOURCE_AUTHOR_SNAPSHOT_ID_EXPORT_STACK', defaultValue: '', description: 'Source Snapshot ID from the Author repository for the stack to export content from')
string(name: 'SOURCE_PUBLISH_SNAPSHOT_ID_EXPORT_STACK', defaultValue: '', description: 'Source Snapshot ID from the Publish repository for the stack to export content from')
string(name: 'SOURCE_SNAPSHOT_STACK_PREFIX_EXPORT_STACK', defaultValue: '', description: 'Source Stack Prefix to get source Snapshot IDs from. for the stack to export content from')
string(name: 'SOURCE_AUTHOR_SNAPSHOT_ID_IMPORT_STACK', defaultValue: '', description: 'Source Snapshot ID from the Author repository for the stack to import content to.')
string(name: 'SOURCE_PUBLISH_SNAPSHOT_ID_IMPORT_STACK', defaultValue: '', description: 'Source Snapshot ID from the Publish repository for the stack to import content to.')
string(name: 'SOURCE_SNAPSHOT_STACK_PREFIX_IMPORT_STACK', defaultValue: '', description: 'Source Stack Prefix to get source Snapshot IDs from for the stack to import content to.')
string(name: 'STACK_PREFIX_EXPORT', defaultValue: 'AEMEXPORT-CON', description: 'AEM OpenCloud Stack to export the Content from.')
string(name: 'STACK_PREFIX_IMPORT', defaultValue: 'AEMIMPORT-CON', description: 'AEM OpenCloud Stack prefix to import the content to.')
}
stages {
stage('Initialise Jenkins pipeline') {
steps {
script {
if (params.ENABLE_SLACK_NOTIFICATIONS == true) {
slackSend (color: '#FFFF00', message: "START: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
JenkinsInit(this, params.AOC_CUSTOM_MANAGER_STEPS_ARTIFACT_URL, env.TMPDIR)
JenkinsPipelinePreStep this
}
}
stage('Prepare AEM OpenCloud libraries and configuration for export stack') {
steps {
JenkinsStagePreStep this
AocPrepareLibrary(this, "aem-aws-stack-builder", params.AOC_VERSION_AEM_AWS_STACK_BUILDER, params.AWS_LIBRARY_S3_BUCKET, params.AWS_LIBRARY_S3_PATH, env.TMPDIR)
AocPrepareLibrary(this, "aem-stack-manager-messenger", params.AOC_VERSION_AEM_STACK_MANAGER_MESSENGER, params.AWS_LIBRARY_S3_BUCKET, params.AWS_LIBRARY_S3_PATH, env.TMPDIR)
AocPrepareConfig(this, params.AOC_CONFIG_ARTIFACT_URL, env.TMPDIR)
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Resolve dependencies for export stack') {
steps {
JenkinsStagePreStep this
ExecCommand(this, env.TMPDIR, "aem-aws-stack-builder", "make deps")
ExecCommand(this, env.TMPDIR, "aem-stack-manager-messenger", "make deps")
ExecCommand(this, env.TMPDIR, "aem-stack-manager-messenger", "make stage")
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Prepare configuration for export stack') {
steps {
JenkinsStagePreStep this
GenerateOfflineSnapshotConfig(this, params.SOURCE_AUTHOR_SNAPSHOT_ID_EXPORT_STACK, params.SOURCE_PUBLISH_SNAPSHOT_ID_EXPORT_STACK, params.SOURCE_SNAPSHOT_STACK_PREFIX_EXPORT_STACK, env.AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_EXPORT)
ExecCommand(this, env.TMPDIR, "aem-aws-stack-builder", "make config config_path=${env.AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_EXPORT}")
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Create AEM Consolidated environment for content export') {
steps {
JenkinsStagePreStep this
AocPrepareParamArtifact(this, params.AOC_DEPLOYMENT_DESCRIPTOR_URL_EXPORT_STACK, env.TMPDIR + '/aem-aws-stack-builder/stage/', 'deploy-artifacts-descriptor.json')
AocPrepareParamArtifact(this, params.AOC_CUSTOM_STACK_PROVISIONER_ARTIFACT_URL, env.TMPDIR + '/aem-aws-stack-builder/stage/', 'aem-custom-stack-provisioner.tar.gz')
ExecCommand(this, env.TMPDIR, "aem-aws-stack-builder", "make create-consolidated config_path=${env.AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_EXPORT} stack_prefix=${params.STACK_PREFIX_EXPORT}")
ExecCommand(this, env.TMPDIR, "aem-stack-manager-msessenger", "make check-readiness-consolidated stack_prefix=${params.STACK_MANAGER_STACK_PREFIX} target_aem_stack_prefix=${params.STACK_PREFIX_EXPORT} config_path=${env.AOC_CONFIG_DIR}/aem-stack-manager-messenger/${params.AOC_CONFIG_PROFILE_AEM_STACK_MANAGER_MESSENGER}/")
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Export Content to S3') {
steps {
JenkinsStagePreStep this
AocPrepareParamArtifact(this, params.AOC_EXPORT_DESCRIPTOR_URL, env.TMPDIR + '/aem-stack-manager-messenger/stage/', 'export-backups-descriptor.json')
AocS3UploadArtifact(this, env.TMPDIR + '/aem-stack-manager-messenger/stage/', 'export-backups-descriptor.json' , params.AWS_LIBRARY_S3_BUCKET, params.STACK_PREFIX_EXPORT)
ExecCommand(this, env.TMPDIR, "aem-stack-manager-messenger", "make export-packages-consolidated stack_prefix=${params.STACK_MANAGER_STACK_PREFIX} target_aem_stack_prefix=${params.STACK_PREFIX_EXPORT} config_path=${env.AOC_CONFIG_DIR}/aem-stack-manager-messenger/${params.AOC_CONFIG_PROFILE_AEM_STACK_MANAGER_MESSENGER}/ descriptor_file='export-backups-descriptor.json'")
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Delete Export AEM Consolidated environment') {
steps {
JenkinsStagePreStep this
// Delete AEM OpenCloud Consolidated Stack
ExecCommand(this, env.TMPDIR, "aem-aws-stack-builder", "make delete-consolidated config_path=${env.AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_EXPORT} stack_prefix=${params.STACK_PREFIX_EXPORT}")
}
post {
always {
// Running stage post-script
JenkinsStagePostStep this
}
}
}
stage('Prepare AEM OpenCloud libraries and configuration for import stack') {
steps {
JenkinsStagePreStep this
AocPrepareLibrary(this, "aem-aws-stack-builder", params.AOC_VERSION_AEM_AWS_STACK_BUILDER, params.AWS_LIBRARY_S3_BUCKET, params.AWS_LIBRARY_S3_PATH, env.TMPDIR)
AocPrepareLibrary(this, "aem-stack-manager-messenger", params.AOC_VERSION_AEM_STACK_MANAGER_MESSENGER, params.AWS_LIBRARY_S3_BUCKET, params.AWS_LIBRARY_S3_PATH, env.TMPDIR)
AocPrepareConfig(this, params.AOC_CONFIG_ARTIFACT_URL, env.TMPDIR)
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Resolve dependencies for import stack') {
steps {
JenkinsStagePreStep this
ExecCommand(this, env.TMPDIR, "aem-aws-stack-builder", "make deps")
ExecCommand(this, env.TMPDIR, "aem-stack-manager-messenger", "make deps")
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Prepare configuration for import stack') {
steps {
JenkinsStagePreStep this
GenerateOfflineSnapshotConfig(this, params.SOURCE_AUTHOR_SNAPSHOT_ID_IMPORT_STACK, params.SOURCE_PUBLISH_SNAPSHOT_ID_IMPORT_STACK, params.SOURCE_SNAPSHOT_STACK_PREFIX_IMPORT_STACK, env.AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_IMPORT)
ExecCommand(this, env.TMPDIR, "aem-aws-stack-builder", "make config config_path=${env.AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_IMPORT}")
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Create Import AEM Consolidated environment') {
steps {
JenkinsStagePreStep this
AocPrepareParamArtifact(this, params.AOC_DEPLOYMENT_DESCRIPTOR_URL_IMPORT_STACK, env.TMPDIR + '/aem-aws-stack-builder/stage/', 'deploy-artifacts-descriptor.json')
AocPrepareParamArtifact(this, params.AOC_CUSTOM_STACK_PROVISIONER_ARTIFACT_URL, env.TMPDIR + '/aem-aws-stack-builder/stage/', 'aem-custom-stack-provisioner.tar.gz')
ExecCommand(this, env.TMPDIR, "aem-aws-stack-builder", "make create-consolidated config_path=${env.AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_IMPORT} stack_prefix=${params.STACK_PREFIX_IMPORT}")
ExecCommand(this, env.TMPDIR, "aem-stack-manager-messenger", "make check-readiness-consolidated stack_prefix=${params.STACK_MANAGER_STACK_PREFIX} target_aem_stack_prefix=${params.STACK_PREFIX_IMPORT} config_path=${env.AOC_CONFIG_DIR}/aem-stack-manager-messenger/${params.AOC_CONFIG_PROFILE_AEM_STACK_MANAGER_MESSENGER}/")
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Import Content to AEM Import Stack') {
steps {
JenkinsStagePreStep this
ExecCommand(this, env.TMPDIR, "aem-stack-manager-messenger", "make import-package stack_prefix=${params.STACK_MANAGER_STACK_PREFIX} target_aem_stack_prefix=${params.STACK_PREFIX_IMPORT} config_path=${env.AOC_CONFIG_DIR}/aem-stack-manager-messenger/${params.AOC_CONFIG_PROFILE_AEM_STACK_MANAGER_MESSENGER}/ component=author-publish-dispatcher aem_id=author source_stack_prefix=${params.STACK_PREFIX_EXPORT} package_group=${params.PACKAGE_GROUP} package_name=${params.PACKAGE_NAME} package_datestamp=${params.PACKAGE_DATESTAMP}")
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Run offline compaction snapshots on import stack') {
steps {
JenkinsStagePreStep this
ExecCommand(this, env.TMPDIR, "aem-stack-manager-messenger", "make offline-compaction-snapshot-consolidated stack_prefix=${params.STACK_MANAGER_STACK_PREFIX} target_aem_stack_prefix=${params.STACK_PREFIX_IMPORT} config_path=${env.AOC_CONFIG_DIR}/aem-stack-manager-messenger/${params.AOC_CONFIG_PROFILE_AEM_STACK_MANAGER_MESSENGER}/")
}
post {
always {
JenkinsStagePostStep this
}
}
}
stage('Delete import AEM Consolidated environment') {
steps {
JenkinsStagePreStep this
ExecCommand(this, env.TMPDIR, "aem-aws-stack-builder", "make delete-consolidated config_path=${env.AOC_CONFIG_PROFILE_DIR_AEM_AWS_STACK_BUILDER_IMPORT} stack_prefix=${params.STACK_PREFIX_IMPORT}")
}
post {
always {
JenkinsStagePostStep this
}
}
}
}
post {
always {
JenkinsPipelinePostStep this
}
success {
script {
if (params.ENABLE_SLACK_NOTIFICATIONS == true) {
slackSend (color: '#00FF00', message: "SUCCESS: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}
failure {
script {
if (params.ENABLE_SLACK_NOTIFICATIONS == true) {
slackSend (color: '#FF0000', message: "FAILURE: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}
}
}
You can’t perform that action at this time.