Validation Implementation
import com.here.platform.ci.*
def node_label = env.NODE_LABEL ? env.NODE_LABEL : 'master'
node(node_label) {
def MAVEN_OPTS = "-B -q -s \$MAVEN_SETTINGS"
CLIHelper cli = new CLIHelper(this)
withCredentials([file(credentialsId: env.OLP_CREDENTIALS_FILE_ID, variable: 'OLP_CREDENTIALS')]) {
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_FILE_ID, variable: 'MAVEN_SETTINGS')]) {
try {
String artifact = "${env.PROJECT_GROUP_ID}:${env.PROJECT_ARTIFACT_ID}:${env.PROJECT_VERSION}:jar"
String deploymentId = "test"
String path_prefix = "${WORKSPACE}/target/dependency/deployments/"
String deployment_config_path = "${path_prefix}/${deploymentId}/deployment.properties"
def deployment
def pipeline_id
def version_id
def pipeline_config_path
def pipeline_config
stage('Initialize') {
cleanWs()
def dependencyPlugin = "org.apache.maven.plugins:maven-dependency-plugin:3.1.1"
sh("mvn ${MAVEN_OPTS} ${dependencyPlugin}:unpack -Dartifact=${artifact}:platform -Dproject.basedir=${WORKSPACE}")
sh("mvn ${MAVEN_OPTS} ${dependencyPlugin}:copy -Dartifact=${artifact}:platform -Dproject.basedir=${WORKSPACE}")
sh("mvn ${MAVEN_OPTS} ${dependencyPlugin}:unpack -Dartifact=${artifact}:it-tests -Dproject.basedir=${WORKSPACE}/test_data")
sh("mvn ${MAVEN_OPTS} ${dependencyPlugin}:copy -Dartifact=${artifact}:it-tests -Dproject.basedir=${WORKSPACE}")
deployment = readProperties(file: deployment_config_path)
deployment.put("suffix", "-${env.BUILD_NUMBER}")
cli.getOlpCliFromSDK(deployment.sdk_version)
}
stage('Prepare test catalogs') {
pipeline_config_path = "${path_prefix}/pipeline-config.conf"
pipeline_config = cli.preparePipelineConfig(pipeline_config_path, path_prefix, deployment)
def input_partition_id = "1475716_20180522155459_20180522153926_20180522155455_10." +
"_48.159957275016836_48.080087029569135_12.040017134498243_11.896950104895032"
def input_partition_file_path = "${WORKSPACE}/test_data/target/dependency/${input_partition_id}"
def partitionID = FileHelper.replaceDateInFileName(input_partition_id)
def layer = "sdii-data-archive"
def partitions_str = "${partitionID}:${input_partition_file_path}"
cli.run(
"olp catalog layer partition put ${pipeline_config["archive-catalog"]} ${layer} "
+ "--partitions " + partitions_str)
}
stage('Create and deploy pipeline') {
def fat_jar_path = FileHelper.findFile(this, "**/*-platform.jar")
def result = cli.deployPipeline(deployment, fat_jar_path, pipeline_config_path)
pipeline_id = result.pipeline_id
version_id = result.version_id
}
stage("Activate pipeline") {
cli.json(
"olp pipeline version activate "
+ "${pipeline_id} ${version_id} ${cli.optional("", deployment.pipeline_activate_options)} ")
}
stage("Wait for pipeline completion") {
def timeoutSeconds = 3000
cli.json(
"olp pipeline version wait --job-state completed "
+ "${pipeline_id} ${version_id} "
+ "--timeout ${timeoutSeconds} "
)
}
stage('Run Product Acceptance Tests') {
def output_partition = "23611423"
cli.run(
"olp catalog layer partition get "
+ "${pipeline_config["output"]} data-learnings "
+ "--partitions ${output_partition} --output ${env.WORKSPACE} ")
def tests_jar_path = FileHelper.findFile(this, "**/*-it-tests.jar")
sh("java -jar -Dpartition=${WORKSPACE}/${output_partition} ${tests_jar_path}")
}
stage('Deploy to production environment') {
build(
job: 'CI-CD-examples/step3',
parameters: [
[
$class: 'StringParameterValue',
name : 'PROJECT_VERSION',
value : env.PROJECT_VERSION
],
[
$class: 'StringParameterValue',
name : 'PROJECT_GROUP_ID',
value : env.PROJECT_GROUP_ID
],
[
$class: 'StringParameterValue',
name : 'PROJECT_ARTIFACT_ID',
value : env.PROJECT_ARTIFACT_ID
]
],
wait: false
)
}
} finally {
stage("Clean-up") {
cli.cleanUp()
}
}
}
}
}