diff --git a/.ci/jenkins/Jenkinsfile.release b/.ci/jenkins/Jenkinsfile.release index a9dcf65b8..9dfaa04ba 100644 --- a/.ci/jenkins/Jenkinsfile.release +++ b/.ci/jenkins/Jenkinsfile.release @@ -4,10 +4,8 @@ import org.jenkinsci.plugins.workflow.libs.Library kogitoRuntimesRepo = 'kogito-runtimes' kogitoAppsRepo = 'kogito-apps' -kogitoExamplesRepo = 'kogito-examples' ARTIFACTS_STAGING_STAGE = 'stage.artifacts.staging' -ARTIFACTS_RELEASE_STAGE = 'stage.artifacts.release' JOB_PROPERTY_PREFIX = 'build' JOB_RESULT_PROPERTY_KEY = 'result' @@ -42,23 +40,17 @@ pipeline { echo "Release properties imported from previous job: ${releaseProperties}" } - assert getDroolsVersion() - assert getKogitoVersion() + assert getReleaseVersion() currentBuild.displayName = getDisplayName() - sendNotification("Release Pipeline has started...\nKogito version = ${getKogitoVersion()}\n=> ${env.BUILD_URL}") - - // Safety measure to not publish to main JBoss - if (getGitAuthor() != 'apache' && !getArtifactsRepositoryParam()) { - sendNotification("Git Author is different from `apache` and no `ARTIFACTS_REPOSITORY` parameter has been provided. Are you sure you want to continue ? => ${env.BUILD_URL}input") - input message: 'Should the pipeline continue with no `ARTIFACTS_REPOSITORY` defined ?', ok: 'Yes' - } + sendNotification("Release Pipeline has started...\nKogito version = ${getReleaseVersion()}\n=> ${env.BUILD_URL}") } } post { always { - setReleasePropertyIfneeded('kogito.version', getKogitoVersion()) + setReleasePropertyIfneeded('release.version', getReleaseVersion()) + setReleasePropertyIfneeded('git.tag.name', getGitTagName()) } } } @@ -66,10 +58,9 @@ pipeline { stage('Build & Deploy Kogito Runtimes') { steps { script { - def buildParams = getDefaultBuildParams(getKogitoVersion()) + def buildParams = getDefaultBuildParams(getReleaseVersion()) addSkipTestsParam(buildParams) - addStringParam(buildParams, 'DROOLS_VERSION', getDroolsVersion()) - + addStringParam(buildParams, 'DROOLS_VERSION', getReleaseVersion()) buildJob(getDeployJobName(kogitoRuntimesRepo), buildParams) } } @@ -78,26 +69,13 @@ pipeline { stage('Build & Deploy Kogito Apps') { steps { script { - def buildParams = getDefaultBuildParams(getKogitoVersion()) + def buildParams = getDefaultBuildParams(getReleaseVersion()) addSkipTestsParam(buildParams) - buildJob(getDeployJobName(kogitoAppsRepo), buildParams) } } } - stage('Build & Deploy Kogito Examples') { - steps { - script { - def buildParams = getDefaultBuildParams(getKogitoVersion()) - addSkipTestsParam(buildParams) - addStringParam(buildParams, 'DROOLS_VERSION', getDroolsVersion()) - - buildJob(getDeployJobName(kogitoExamplesRepo), buildParams) - } - } - } - stage('Artifacts\' staging finalization') { steps { script { @@ -109,80 +87,15 @@ pipeline { } } - stage('Are staged artifacts released?') { - when { - // Execute only if artifacts repository was not given, which means the staging repository has been created - expression { return !getArtifactsRepositoryParam() && !areArtifactsReleased() } - } - steps { - script { - String body = "${getKogitoVersion()} artifacts are ready for release.\n" + - "Please release the staging repositories and then confirm here: ${env.BUILD_URL}input" - sendNotification(body) - input message: 'Has the staging repository been released ?', ok: 'Yes' - - sendNotification('Artifacts have been released. Finalizing now the release ...') - setArtifactsReleased() - } - } - } - - stage('Promote Kogito Runtimes') { - when { - expression { return isJobConsideredOk(getDeployJobName(kogitoRuntimesRepo)) } - } - steps { - script { - def buildParams = getDefaultBuildParams(getKogitoVersion()) - addDeployBuildUrlParam(buildParams, getDeployJobName(kogitoRuntimesRepo)) - addStringParam(buildParams, 'DROOLS_VERSION', getDroolsVersion()) - - buildJob(getPromoteJobName(kogitoRuntimesRepo), buildParams) - } - } - } - - stage('Promote Kogito Apps') { - when { - expression { return isJobConsideredOk(getDeployJobName(kogitoAppsRepo)) } - } - steps { - script { - def buildParams = getDefaultBuildParams(getKogitoVersion()) - addDeployBuildUrlParam(buildParams, getDeployJobName(kogitoAppsRepo)) - - buildJob(getPromoteJobName(kogitoAppsRepo), buildParams) - } - } - } - - stage('Promote Kogito Examples') { - when { - expression { return isJobConsideredOk(getDeployJobName(kogitoExamplesRepo)) } - } - steps { - script { - def buildParams = getDefaultBuildParams(getKogitoVersion()) - addStringParam(buildParams, 'DROOLS_VERSION', getDroolsVersion()) - addDeployBuildUrlParam(buildParams, getDeployJobName(kogitoExamplesRepo)) - addBooleanParam(buildParams, 'UPDATE_STABLE_BRANCH', isDeployAsLatest()) - - buildJob(getPromoteJobName(kogitoExamplesRepo), buildParams) - } - } - } - stage('Start Cloud release') { when { expression { isCloudRelease() } } steps { script { - def buildParams = getDefaultBuildParams(getKogitoVersion()) - addStringParam(buildParams, 'KOGITO_VERSION', getKogitoVersion()) - addBooleanParam(buildParams, 'DEPLOY_AS_LATEST', isDeployAsLatest()) + def buildParams = getDefaultBuildParams(getReleaseVersion()) + addStringParam(buildParams, 'RELEASE_VERSION', getReleaseVersion()) addSkipTestsParam(buildParams) - build(job: './0-kogito-release-cloud', wait: false, parameters: buildParams, propagate: false) } } @@ -257,10 +170,6 @@ String getDeployJobName(String repository) { return "${repository}-deploy" } -String getPromoteJobName(String repository) { - return "${repository}-promote" -} - String getJobPropertySuffix(String jobName) { return "${JOB_PROPERTY_PREFIX}.${jobName}" } @@ -358,6 +267,7 @@ List getDefaultBuildParams(String version) { addDisplayNameParam(buildParams, getDisplayName(version)) addStringParam(buildParams, 'PROJECT_VERSION', version) addStringParam(buildParams, 'KOGITO_PR_BRANCH', "kogito-${version}") + addStringParam(buildParams, 'GIT_TAG_NAME', getGitTagName()) return buildParams } @@ -396,34 +306,22 @@ String constructKey(String prefix, String paramId) { } String getDisplayName(version = '') { - version = version ?: getKogitoVersion() + version = version ?: getReleaseVersion() return "Release ${version}" } -String getKogitoVersion() { - return params.KOGITO_VERSION ?: getReleaseProperty('kogito.version') +String getReleaseVersion() { + return params.RELEASE_VERSION ?: getReleaseProperty('release.version') } -String getDroolsVersion() { - return params.DROOLS_VERSION ?: getReleaseProperty('drools.version') +String getGitTagName() { + return params.GIT_TAG_NAME ?: getReleaseProperty('git.tag.name') } String getGitAuthor() { return env.GIT_AUTHOR } -String getArtifactsRepositoryParam() { - return env['ARTIFACTS_REPOSITORY'] ?: '' -} - -String getStagingRepository() { - return getArtifactsRepositoryParam() ?: env.DEFAULT_STAGING_REPOSITORY -} - -boolean isDeployAsLatest() { - return params.DEPLOY_AS_LATEST || getReleaseProperty('deploy.latest')?.toBoolean() -} - boolean isCloudRelease() { return !params.SKIP_CLOUD_RELEASE } @@ -455,11 +353,3 @@ boolean areArtifactsStaged() { void setArtifactsStaged() { setReleasePropertyIfneeded(ARTIFACTS_STAGING_STAGE, true) } - -boolean areArtifactsReleased() { - return hasReleaseProperty(ARTIFACTS_RELEASE_STAGE) -} - -void setArtifactsReleased() { - setReleasePropertyIfneeded(ARTIFACTS_RELEASE_STAGE, true) -} diff --git a/.ci/jenkins/Jenkinsfile.release.cloud b/.ci/jenkins/Jenkinsfile.release.cloud index 12d4f897c..86ccc37b4 100644 --- a/.ci/jenkins/Jenkinsfile.release.cloud +++ b/.ci/jenkins/Jenkinsfile.release.cloud @@ -3,10 +3,6 @@ import org.jenkinsci.plugins.workflow.libs.Library @Library('jenkins-pipeline-shared-libraries')_ kogitoImagesRepo = 'kogito-images' -kogitoServerlessOperatorRepo = 'kogito-serverless-operator' - -ARTIFACTS_STAGING_STAGE = 'stage.artifacts.staging' -ARTIFACTS_RELEASE_STAGE = 'stage.artifacts.release' JOB_PROPERTY_PREFIX = 'build' JOB_RESULT_PROPERTY_KEY = 'result' @@ -18,7 +14,6 @@ releaseProperties = [:] defaultImageParamsPrefix = 'IMAGE' baseImageParamsPrefix = 'BASE_IMAGE' -promoteImageParamsPrefix = 'PROMOTE_IMAGE' pipeline { agent { @@ -45,19 +40,17 @@ pipeline { echo "Release properties imported from previous job: ${releaseProperties}" } - assert getKogitoVersion() + assert getReleaseVersion() currentBuild.displayName = getDisplayName() - sendNotification("Cloud Release Pipeline has started...\nKogito version = ${getKogitoVersion()}\n=> ${env.BUILD_URL}") + sendNotification("Cloud Release Pipeline has started...\nKogito version = ${getReleaseVersion()}\n=> ${env.BUILD_URL}") } } post { always { - setReleasePropertyIfneeded('kogito.version', getKogitoVersion()) - setReleasePropertyIfneeded('kogito.images.version', getKogitoImagesVersion()) - setReleasePropertyIfneeded('kogito.serverless.operator.version', getKogitoServerlessOperatorVersion()) - setReleasePropertyIfneeded('deploy.latest', isDeployAsLatest()) + setReleasePropertyIfneeded('release.version', getReleaseVersion()) + setReleasePropertyIfneeded('git.tag.name', getGitTagName()) } } } @@ -66,7 +59,7 @@ pipeline { steps { script { env.APPS_URI = params.APPS_URI ?: (getReleaseProperty('apps.uri') ?: "https://github.com/${getGitAuthor()}/incubator-kie-kogito-apps") - env.APPS_REF = params.APPS_REF ?: (getReleaseProperty('apps.ref') ?: getKogitoVersion()) + env.APPS_REF = params.APPS_REF ?: (getReleaseProperty('apps.ref') ?: getReleaseVersion()) echo "Got apps uri ${env.APPS_URI}" echo "Got apps ref ${env.APPS_REF}" @@ -83,70 +76,15 @@ pipeline { } steps { script { - def buildParams = getDefaultBuildParams(getKogitoImagesVersion()) - addStringParam(buildParams, 'KOGITO_ARTIFACTS_VERSION', getKogitoVersion()) - addImageBuildParams(buildParams, getKogitoImagesTempTag()) + def buildParams = getDefaultBuildParams(getReleaseVersion()) + addImageBuildParams(buildParams, getReleaseVersion()) addAppsParam(buildParams) addSkipTestsParam(buildParams) - addExamplesParam(buildParams) buildJob(getDeployJobName(kogitoImagesRepo), buildParams) } } } - - // stage('Build & Deploy Kogito Serverless Operator') { - // when { - // expression { return isServerlessOperatorRelease() } - // } - // steps { - // script { - // def buildParams = getDefaultBuildParams(getKogitoServerlessOperatorVersion()) - // addSkipTestsParam(buildParams) - // addImageBuildParams(buildParams, getKogitoServerlessOperatorTempTag()) - - // buildJob(getDeployJobName(kogitoServerlessOperatorRepo), buildParams) - // } - // } - // } - - // stage('Promote Kogito Images') { - // when { - // expression { return isImagesRelease() && isJobConsideredOk(getDeployJobName(kogitoImagesRepo)) } - // } - // steps { - // script { - // def buildParams = getDefaultBuildParams(getKogitoImagesVersion()) - // addDeployBuildUrlParamOrClosure(buildParams, getDeployJobName(kogitoImagesRepo)) { - // addImageBuildParams(buildParams, getKogitoImagesTempTag(), false, baseImageParamsPrefix) - // } - // addImageBuildParams(buildParams, getKogitoImagesFinalTag(), true, promoteImageParamsPrefix) - // addBooleanParam(buildParams, 'DEPLOY_WITH_LATEST_TAG', isDeployAsLatest()) - - // buildJob(getPromoteJobName(kogitoImagesRepo), buildParams) - // } - // } - // } - - // stage('Promote Kogito Serverless Operator') { - // when { - // expression { return isServerlessOperatorRelease() && isJobConsideredOk(getDeployJobName(kogitoServerlessOperatorRepo)) } - // } - // steps { - // script { - // def buildParams = getDefaultBuildParams(getKogitoServerlessOperatorVersion()) - // addDeployBuildUrlParamOrClosure(buildParams, getDeployJobName(kogitoServerlessOperatorRepo)) { - // addImageBuildParams(buildParams, getKogitoServerlessOperatorTempTag(), false, baseImageParamsPrefix) - // } - - // // Base image information is given by the deploy URL - // addImageBuildParams(buildParams, getKogitoServerlessOperatorFinalTag(), true, promoteImageParamsPrefix) - // addBooleanParam(buildParams, 'DEPLOY_WITH_LATEST_TAG', isDeployAsLatest()) - - // buildJob(getPromoteJobName(kogitoServerlessOperatorRepo), buildParams) - // } - // } - // } } post { always { @@ -217,10 +155,6 @@ String getDeployJobName(String repository) { return "${repository}-deploy" } -String getPromoteJobName(String repository) { - return "${repository}-promote" -} - String getJobPropertySuffix(String jobName) { return "${JOB_PROPERTY_PREFIX}.${jobName}" } @@ -318,6 +252,7 @@ List getDefaultBuildParams(String version) { addDisplayNameParam(buildParams, getDisplayName(version)) addStringParam(buildParams, 'PROJECT_VERSION', version) addStringParam(buildParams, 'KOGITO_PR_BRANCH', params.KOGITO_PR_BRANCH ?: "kogito-${version}") + addStringParam(buildParams, 'GIT_TAG_NAME', getGitTagName()) return buildParams } @@ -349,11 +284,11 @@ void addAppsParam(buildParams) { } void addImageBuildParams(List buildParams, String tag, boolean isFinalImage = false, String paramsPrefix = defaultImageParamsPrefix) { - addBooleanParam(buildParams, constructKey(paramsPrefix, 'USE_OPENSHIFT_REGISTRY'), !isFinalImage && params.USE_TEMP_OPENSHIFT_REGISTRY) - addStringParam(buildParams, constructKey(paramsPrefix, 'REGISTRY_USER_CREDENTIALS_ID'), env.IMAGE_REGISTRY_USER_CREDENTIALS_ID) - addStringParam(buildParams, constructKey(paramsPrefix, 'REGISTRY_TOKEN_CREDENTIALS_ID'), env.IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID) - addStringParam(buildParams, constructKey(paramsPrefix, 'REGISTRY'), env.IMAGE_REGISTRY) - addStringParam(buildParams, constructKey(paramsPrefix, 'NAMESPACE'), env.IMAGE_NAMESPACE) + addBooleanParam(buildParams, constructKey(paramsPrefix, 'USE_OPENSHIFT_REGISTRY'), false) + addStringParam(buildParams, constructKey(paramsPrefix, 'REGISTRY_USER_CREDENTIALS_ID'), '') + addStringParam(buildParams, constructKey(paramsPrefix, 'REGISTRY_TOKEN_CREDENTIALS_ID'), '') + addStringParam(buildParams, constructKey(paramsPrefix, 'REGISTRY'), '') + addStringParam(buildParams, constructKey(paramsPrefix, 'NAMESPACE'), '') addStringParam(buildParams, constructKey(paramsPrefix, 'TAG'), tag) } @@ -370,57 +305,24 @@ String constructKey(String prefix, String paramId) { } String getDisplayName(version = '') { - version = version ?: getKogitoVersion() + version = version ?: getReleaseVersion() return "Release ${version}" } -String getKogitoVersion() { - return params.KOGITO_VERSION ?: getReleaseProperty('kogito.version') -} - -String getKogitoImagesVersion() { - return params.KOGITO_IMAGES_VERSION ?: (getReleaseProperty('kogito.images.version') ?: removeVersionSuffixIfExist(getKogitoVersion())) -} - -String getKogitoServerlessOperatorVersion() { - return params.KOGITO_SERVERLESS_OPERATOR_VERSION ?: (getReleaseProperty('kogito.serverless.operator.version') ?: removeVersionSuffixIfExist(getKogitoVersion())) +String getReleaseVersion() { + return params.RELEASE_VERSION ?: getReleaseProperty('release.version') } String getGitAuthor() { return env.GIT_AUTHOR } -boolean isDeployAsLatest() { - return params.DEPLOY_AS_LATEST || getReleaseProperty('deploy.latest')?.toBoolean() -} - boolean isImagesRelease() { return !params.SKIP_IMAGES_RELEASE } -boolean isServerlessOperatorRelease() { - return !params.SKIP_SERVERLESS_OPERATOR_RELEASE -} - -String getKogitoImagesTempTag() { - return "${getKogitoImagesVersion()}-temp".toLowerCase() -} - -String getKogitoImagesFinalTag() { - return "${getKogitoImagesVersion()}".toLowerCase() -} - -String getKogitoServerlessOperatorTempTag() { - return "${getKogitoServerlessOperatorVersion()}-temp".toLowerCase() -} - -String getKogitoServerlessOperatorFinalTag() { - return "${getKogitoServerlessOperatorVersion()}".toLowerCase() -} - -String removeVersionSuffixIfExist(String version) { - Integer[] versionSplit = util.parseVersion(version) - return "${versionSplit[0]}.${versionSplit[1]}.${versionSplit[2]}" +String getGitTagName() { + return params.GIT_TAG_NAME ?: getReleaseProperty('git.tag.name') } void setReleasePropertyIfneeded(String key, def value) { diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index 68578b345..7cbbf2a8c 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -290,9 +290,8 @@ void setupReleaseArtifactsJob() { parameters { stringParam('RESTORE_FROM_PREVIOUS_JOB', '', 'URL to a previous stopped release job which needs to be continued') - stringParam('KOGITO_VERSION', '', 'Kogito version to release as Major.minor.micro') - stringParam('DROOLS_VERSION', '', 'Drools version to set for the release') - booleanParam('DEPLOY_AS_LATEST', false, 'Given project version is considered the latest version') + stringParam('RELEASE_VERSION', '', 'Version to release as Major.minor.micro') + stringParam('GIT_TAG_NAME', '', 'Git tag to create. i.e.: 10.0.0-rc1') booleanParam('SKIP_TESTS', false, 'Skip all tests') @@ -308,21 +307,13 @@ void setupReleaseCloudJob() { GIT_BRANCH_NAME: "${GIT_BRANCH}", GIT_AUTHOR: "${GIT_AUTHOR_NAME}", - - IMAGE_REGISTRY_USER_CREDENTIALS_ID: "${CLOUD_IMAGE_REGISTRY_USER_CREDENTIALS_ID}", - IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID: "${CLOUD_IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID}", - IMAGE_REGISTRY: "${CLOUD_IMAGE_REGISTRY}", - IMAGE_NAMESPACE: "${CLOUD_IMAGE_NAMESPACE}", - BRANCH_FOR_LATEST: "${CLOUD_IMAGE_LATEST_GIT_BRANCH}", ]) KogitoJobTemplate.createPipelineJob(this, jobParams)?.with { parameters { stringParam('RESTORE_FROM_PREVIOUS_JOB', '', 'URL to a previous stopped release job which needs to be continued') - stringParam('KOGITO_VERSION', '', 'Kogito version to release as Major.minor.micro') - stringParam('KOGITO_IMAGES_VERSION', '', '(optional) To be set if different from KOGITO_VERSION. Should be only a bug fix update from KOGITO_VERSION.') - stringParam('KOGITO_SERVERLESS_OPERATOR_VERSION', '', '(optional) To be set if different from KOGITO_VERSION. Should be only a bug fix update from KOGITO_VERSION.') - booleanParam('DEPLOY_AS_LATEST', false, 'Given project version is considered the latest version') + stringParam('RELEASE_VERSION', '', 'Version to release as Major.minor.micro. i.e: 10.0.0') + stringParam('GIT_TAG_NAME', '', 'Git tag to create. i.e.: 10.0.0-rc1') stringParam('APPS_URI', '', 'Override default. Git uri to the kogito-apps repository to use for building images.') stringParam('APPS_REF', '', 'Override default. Git reference (branch/tag) to the kogito-apps repository to use for building images.') @@ -330,9 +321,6 @@ void setupReleaseCloudJob() { booleanParam('SKIP_TESTS', false, 'Skip all tests') booleanParam('SKIP_IMAGES_RELEASE', false, 'To skip Images Test & Deployment.') - booleanParam('SKIP_SERVERLESS_OPERATOR_RELEASE', false, 'To skip Serverless Operator Test & Deployment.') - - booleanParam('USE_TEMP_OPENSHIFT_REGISTRY', false, 'If enabled, use Openshift registry to push temporary images') } } }