From 70dd58581467c1113dbc4e5dd1b61c1c0469dc1d Mon Sep 17 00:00:00 2001 From: Fabrizio Antonangeli Date: Thu, 7 Nov 2024 18:39:07 +0100 Subject: [PATCH] kie-issues#2693: [SonataFlow] SonataFlow Management Console on KIE Tools release job (#2694) --- .../Jenkinsfile.sonataflow-management-console | 209 ++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 .ci/jenkins/release-jobs/Jenkinsfile.sonataflow-management-console diff --git a/.ci/jenkins/release-jobs/Jenkinsfile.sonataflow-management-console b/.ci/jenkins/release-jobs/Jenkinsfile.sonataflow-management-console new file mode 100644 index 00000000000..2ec866f42de --- /dev/null +++ b/.ci/jenkins/release-jobs/Jenkinsfile.sonataflow-management-console @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +pipeline { + agent { + docker { + image 'docker.io/apache/incubator-kie-tools-ci-build:main' + args '--shm-size=2g --privileged --group-add docker' + } + } + + options { + timeout(time: 60, unit: 'MINUTES') + } + + parameters { + booleanParam(description: 'Dry run', name: 'DRY_RUN', defaultValue: true) + string(description: 'Release Version', name: 'RELEASE_VERSION', defaultValue: '0.0.0') + string(description: 'Base Ref', name: 'BASE_REF') + string(description: 'Release Candidate Version', name: 'RELEASE_CANDIDATE_VERSION', defaultValue: '') + } + + environment { + KIE_TOOLS_BUILD__runLinters = 'false' + KIE_TOOLS_BUILD__runTests = 'false' + KIE_TOOLS_BUILD__runEndToEndTests = 'false' + KIE_TOOLS_BUILD__buildContainerImages = 'true' + + SONATAFLOW_MANAGEMENT_CONSOLE__registry = 'docker.io' + SONATAFLOW_MANAGEMENT_CONSOLE__account = 'apache' + SONATAFLOW_MANAGEMENT_CONSOLE__name = 'incubator-kie-sonataflow-management-console' + SONATAFLOW_MANAGEMENT_CONSOLE__buildTag = "latest ${params.RELEASE_VERSION}" + + RELEASE_ARTIFACTS_DIR = "${WORKSPACE}/release-artifacts" + + DOCKER_CONFIG = "${WORKSPACE}/.docker" + + PNPM_FILTER_STRING = '-F @kie-tools/sonataflow-management-console-image...' + } + + stages { + stage('Load local shared scripts') { + steps { + script { + pipelineVars = load '.ci/jenkins/shared-scripts/pipelineVars.groovy' + buildUtils = load '.ci/jenkins/shared-scripts/buildUtils.groovy' + githubUtils = load '.ci/jenkins/shared-scripts/githubUtils.groovy' + dockerUtils = load '.ci/jenkins/shared-scripts/dockerUtils.groovy' + releaseUtils = load '.ci/jenkins/shared-scripts/releaseUtils.groovy' + } + } + } + + stage('Start required services for build and tests (DinD, Xvfb, Fluxbox)') { + steps { + script { + buildUtils.startRequiredServices() + } + } + } + + stage('Clean workspace before build') { + steps { + cleanWs(deleteDirs: true, disableDeferredWipeout: true) + } + } + + stage('Load upstream images') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' } + } + steps { + script { + upstreamReleaseArtifactsDir = "${WORKSPACE}/upstream-release-artifacts" + releaseUtils.downloadReleaseArtifacts("${pipelineVars.asfReleaseStagingRepository}", "${upstreamReleaseArtifactsDir}", "${params.RELEASE_CANDIDATE_VERSION}") + upstreamImagesArtifacts = releaseUtils.getUpstreamImagesArtifactsList("${upstreamReleaseArtifactsDir}", "${params.RELEASE_CANDIDATE_VERSION}") + dockerUtils.loadImages(upstreamImagesArtifacts as String[]) + } + } + } + + stage('Checkout kie-tools') { + steps { + dir('kie-tools') { + script { + githubUtils.checkoutRepo( + "http://github.com/${pipelineVars.githubRepositorySlug}.git", + "${params.BASE_REF}", + "${pipelineVars.kieToolsBotGithubCredentialsId}" + ) + } + } + } + } + + stage('Setup PNPM') { + steps { + dir('kie-tools') { + script { + buildUtils.setupPnpm("${pipelineVars.mavenSettingsReleaseConfigFileId}") + } + } + } + } + + stage('PNPM Bootstrap') { + steps { + dir('kie-tools') { + script { + buildUtils.pnpmBootstrap("${env.PNPM_FILTER_STRING}") + } + } + } + } + + stage('Build') { + steps { + dir('kie-tools') { + script { + buildUtils.pnpmBuild("${env.PNPM_FILTER_STRING}") + } + } + } + } + + stage('Push sonataflow-management-console to Docker Hub') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION == '' } + } + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.SONATAFLOW_MANAGEMENT_CONSOLE__registry}", + "${env.SONATAFLOW_MANAGEMENT_CONSOLE__account}", + "${env.SONATAFLOW_MANAGEMENT_CONSOLE__name}", + "${env.SONATAFLOW_MANAGEMENT_CONSOLE__buildTag}", + "${pipelineVars.dockerHubUserCredentialsId}", + "${pipelineVars.dockerHubTokenCredentialsId}" + ) + } + } + } + + stage('Setup release candidate artifacts') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' } + } + steps { + script { + env.RELEASE_IMAGE_TAR_FILE = "incubator-kie-${params.RELEASE_CANDIDATE_VERSION}-sonataflow-management-console-image.tar.gz" + + sh """#!/bin/bash -el + mkdir ${env.RELEASE_ARTIFACTS_DIR} + docker save "${env.SONATAFLOW_MANAGEMENT_CONSOLE__registry}/${env.SONATAFLOW_MANAGEMENT_CONSOLE__account}/${env.SONATAFLOW_MANAGEMENT_CONSOLE__name}:${params.RELEASE_VERSION}" | gzip > "${env.RELEASE_ARTIFACTS_DIR}/${env.RELEASE_IMAGE_TAR_FILE}" + """.trim() + } + } + } + + stage('Sign artifact for Apache release') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' } + } + steps { + dir("${env.RELEASE_ARTIFACTS_DIR}") { + script { + releaseUtils.setupSigningKey("${pipelineVars.asfReleaseGPGKeyCredentialsId}") + releaseUtils.signArtifact("${env.RELEASE_IMAGE_TAR_FILE}") + } + } + } + } + + stage('Publish Release Candidate artifacts') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' } + } + steps { + script { + releaseUtils.publishArtifacts( + "${env.RELEASE_ARTIFACTS_DIR}", + "${pipelineVars.asfReleaseStagingRepository}", + "${params.RELEASE_CANDIDATE_VERSION}", + "${pipelineVars.asfReleaseSVNStagingCredentialsId}" + ) + } + } + } + } + + post { + always { + cleanWs(deleteDirs: true) + } + } +}