Copilot commented on code in PR #7123: URL: https://github.com/apache/incubator-kie/pull/7123#discussion_r4490909114
########## .ci/jenkins/Jenkinsfile.103xplus.release-candidate: ########## @@ -0,0 +1,181 @@ +/* + * 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. + */ + +// 10.3.x+ release pipeline — fully independent, no kogito-pipelines / jobs.groovy dependency. +// - No @Library, no DSL-injected env vars, no drools-deploy / drools-promote downstream jobs +// - Create a plain "Pipeline script from SCM" job pointing at this file and run it +// with a few parameters. Everything it needs is a parameter (with a default). +// - Runs script/release/release-all.sh (R commit + RC tag -> build -> Nexus staging) +// +// MANDATORY parameters : RELEASE_VERSION, TAG_NAME +// Real RC run : DEPLOY=true, PUSH_TAG=true, DRY_RUN=false (the defaults) +// Branch cut (once per minor, before rc1 only): +// CREATE_STREAM_BRANCH=true -> creates X.Y.x from main, +// sets X.Y.999-SNAPSHOT, pushes it, then continues the RC on X.Y.x. +// Leave it false for rc2, final and patch releases (branch already exists). + +pipeline { + agent { + label 'ubuntu' + } + + tools { + maven 'maven_3.9.16' + jdk 'jdk_17_latest' + } + + options { + timestamps() + timeout(time: 360, unit: 'MINUTES') + } + + parameters { + string(name: 'RELEASE_VERSION', defaultValue: '', description: 'MANDATORY. Exact release version, e.g. 10.3.0', trim: true) + string(name: 'TAG_NAME', defaultValue: '', description: 'MANDATORY. RC tag name, e.g. 10.3.0-rc1 (must start with RELEASE_VERSION and be a new tag)', trim: true) + booleanParam(name: 'CREATE_STREAM_BRANCH', defaultValue: false, description: 'Branch cut: create X.Y.x (derived from RELEASE_VERSION) from main, set X.Y.999-SNAPSHOT and push it BEFORE building the RC. Only for the first RC of a new minor (e.g. 10.3.0-rc1). Fails if X.Y.x already exists') + booleanParam(name: 'SKIP_TESTS', defaultValue: true, description: 'Skip running tests during reactor build') + booleanParam(name: 'DEPLOY', defaultValue: true, description: 'Deploy artifacts to Apache Nexus staging') + string(name: 'STAGING_URL', defaultValue: '', description: 'Custom Nexus staging URL (optional)') + booleanParam(name: 'PUSH_TAG', defaultValue: true, description: 'Push the git tag to origin') + string(name: 'EXTRA_MAVEN_OPTS', defaultValue: '', description: 'Extra Maven CLI options to pass to build.sh') + booleanParam(name: 'DRY_RUN', defaultValue: false, description: 'Dry run without making remote git or staging changes') + + // Jenkins IDs — defaults match the existing KIE Jenkins; override only if they differ. + string(name: 'MAVEN_SETTINGS_CONFIG_FILE_ID', defaultValue: 'kie-release-authn-settings', description: 'Config File Provider ID of the Maven settings.xml (must define server "apache.releases.https")', trim: true) + string(name: 'GPG_KEY_CREDS_ID', defaultValue: 'GPG_KEY_FILE', description: 'Secret FILE credential ID holding the armored GPG private key', trim: true) + string(name: 'GPG_PASSPHRASE_CREDS_ID', defaultValue: '', description: 'Optional. Secret TEXT credential ID holding the GPG key passphrase. Leave empty if the key has no passphrase (KIE release key has none)', trim: true) + string(name: 'GIT_PUSH_CREDS_ID', defaultValue: '84811880-2025-45b6-a44c-2f33bef30ad2', description: 'Username/password credential ID used to push the RC tag to GitHub', trim: true) + } + + stages { + stage('Initialize & Validate') { + steps { + script { + if (!params.RELEASE_VERSION?.trim()) { + error 'RELEASE_VERSION parameter is mandatory (e.g. 10.3.0)' + } + if (!params.TAG_NAME?.trim()) { + error 'TAG_NAME parameter is mandatory (e.g. 10.3.0-rc1)' + } + if (!params.TAG_NAME.startsWith(params.RELEASE_VERSION)) { + error "TAG_NAME '${params.TAG_NAME}' must start with RELEASE_VERSION '${params.RELEASE_VERSION}'" + } + currentBuild.displayName = "Release ${params.RELEASE_VERSION} (${params.TAG_NAME})" + } + } + } + + stage('Create Stream Branch') { + when { + expression { return params.CREATE_STREAM_BRANCH } + } + steps { + script { + withCredentials([usernamePassword(credentialsId: params.GIT_PUSH_CREDS_ID, usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN')]) { + def branchArgs = [ + './script/release/00-create-stream-branch.sh', + '--version', params.RELEASE_VERSION, + '--base', 'main', + '--push' + ] + if (params.DRY_RUN) branchArgs << '--dry-run' + + sh """#!/usr/bin/env bash + set -euo pipefail + git config user.email "[email protected]" + git config user.name "Apache KIE Release Bot" + git config --local credential.helper '!f() { echo username=\$GITHUB_USER; echo password=\$GITHUB_TOKEN; }; f' + chmod +x script/release/*.sh + ${branchArgs.collect { "'${it.replace("'", "'\\''")}'" }.join(' ')} + """ + } + } + } + } + + stage('Execute Release Scripts') { + steps { + // The Maven settings id is a Config File Provider id (not a secret) and is + // exposed as MAVEN_SETTINGS_FILE. GPG key/passphrase and the GitHub push + // credential are real credentials and use withCredentials. + script { + def creds = [ + file(credentialsId: params.GPG_KEY_CREDS_ID, variable: 'GPG_KEY_FILE_PATH'), + usernamePassword(credentialsId: params.GIT_PUSH_CREDS_ID, usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN') + ] + // Passphrase is optional: the KIE release signing key has none. + if (params.GPG_PASSPHRASE_CREDS_ID?.trim()) { + creds << string(credentialsId: params.GPG_PASSPHRASE_CREDS_ID, variable: 'MAVEN_GPG_PASSPHRASE') + } + configFileProvider([configFile(fileId: params.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) { + withCredentials(creds) { + // Import the signing key so the apache-release profile can sign + // artifacts. Passphrase is supplied later via MAVEN_GPG_PASSPHRASE. + sh '''#!/usr/bin/env bash + set -euo pipefail + gpg --batch --pinentry-mode=loopback --import "$GPG_KEY_FILE_PATH" Review Comment: This imports the release private key into the Ubuntu agent's default `~/.gnupg`, outside the workspace. Neither `withCredentials` nor `cleanWs` removes imported keys, so on a reused agent the signing key remains available to subsequent jobs running as the same user. Use a private, build-specific `GNUPGHOME` for both import and Maven signing, and remove it and its agent in guaranteed cleanup. ########## .ci/jenkins/Jenkinsfile.103xplus.release-candidate: ########## @@ -0,0 +1,181 @@ +/* + * 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. + */ + +// 10.3.x+ release pipeline — fully independent, no kogito-pipelines / jobs.groovy dependency. +// - No @Library, no DSL-injected env vars, no drools-deploy / drools-promote downstream jobs +// - Create a plain "Pipeline script from SCM" job pointing at this file and run it +// with a few parameters. Everything it needs is a parameter (with a default). +// - Runs script/release/release-all.sh (R commit + RC tag -> build -> Nexus staging) +// +// MANDATORY parameters : RELEASE_VERSION, TAG_NAME +// Real RC run : DEPLOY=true, PUSH_TAG=true, DRY_RUN=false (the defaults) +// Branch cut (once per minor, before rc1 only): +// CREATE_STREAM_BRANCH=true -> creates X.Y.x from main, +// sets X.Y.999-SNAPSHOT, pushes it, then continues the RC on X.Y.x. +// Leave it false for rc2, final and patch releases (branch already exists). + +pipeline { + agent { + label 'ubuntu' + } + + tools { + maven 'maven_3.9.16' + jdk 'jdk_17_latest' + } + + options { + timestamps() + timeout(time: 360, unit: 'MINUTES') + } + + parameters { + string(name: 'RELEASE_VERSION', defaultValue: '', description: 'MANDATORY. Exact release version, e.g. 10.3.0', trim: true) + string(name: 'TAG_NAME', defaultValue: '', description: 'MANDATORY. RC tag name, e.g. 10.3.0-rc1 (must start with RELEASE_VERSION and be a new tag)', trim: true) + booleanParam(name: 'CREATE_STREAM_BRANCH', defaultValue: false, description: 'Branch cut: create X.Y.x (derived from RELEASE_VERSION) from main, set X.Y.999-SNAPSHOT and push it BEFORE building the RC. Only for the first RC of a new minor (e.g. 10.3.0-rc1). Fails if X.Y.x already exists') + booleanParam(name: 'SKIP_TESTS', defaultValue: true, description: 'Skip running tests during reactor build') + booleanParam(name: 'DEPLOY', defaultValue: true, description: 'Deploy artifacts to Apache Nexus staging') + string(name: 'STAGING_URL', defaultValue: '', description: 'Custom Nexus staging URL (optional)') + booleanParam(name: 'PUSH_TAG', defaultValue: true, description: 'Push the git tag to origin') + string(name: 'EXTRA_MAVEN_OPTS', defaultValue: '', description: 'Extra Maven CLI options to pass to build.sh') + booleanParam(name: 'DRY_RUN', defaultValue: false, description: 'Dry run without making remote git or staging changes') + + // Jenkins IDs — defaults match the existing KIE Jenkins; override only if they differ. + string(name: 'MAVEN_SETTINGS_CONFIG_FILE_ID', defaultValue: 'kie-release-authn-settings', description: 'Config File Provider ID of the Maven settings.xml (must define server "apache.releases.https")', trim: true) + string(name: 'GPG_KEY_CREDS_ID', defaultValue: 'GPG_KEY_FILE', description: 'Secret FILE credential ID holding the armored GPG private key', trim: true) + string(name: 'GPG_PASSPHRASE_CREDS_ID', defaultValue: '', description: 'Optional. Secret TEXT credential ID holding the GPG key passphrase. Leave empty if the key has no passphrase (KIE release key has none)', trim: true) + string(name: 'GIT_PUSH_CREDS_ID', defaultValue: '84811880-2025-45b6-a44c-2f33bef30ad2', description: 'Username/password credential ID used to push the RC tag to GitHub', trim: true) + } + + stages { + stage('Initialize & Validate') { + steps { + script { + if (!params.RELEASE_VERSION?.trim()) { + error 'RELEASE_VERSION parameter is mandatory (e.g. 10.3.0)' + } + if (!params.TAG_NAME?.trim()) { + error 'TAG_NAME parameter is mandatory (e.g. 10.3.0-rc1)' + } + if (!params.TAG_NAME.startsWith(params.RELEASE_VERSION)) { + error "TAG_NAME '${params.TAG_NAME}' must start with RELEASE_VERSION '${params.RELEASE_VERSION}'" + } + currentBuild.displayName = "Release ${params.RELEASE_VERSION} (${params.TAG_NAME})" + } + } + } + + stage('Create Stream Branch') { + when { + expression { return params.CREATE_STREAM_BRANCH } + } + steps { + script { + withCredentials([usernamePassword(credentialsId: params.GIT_PUSH_CREDS_ID, usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN')]) { + def branchArgs = [ + './script/release/00-create-stream-branch.sh', + '--version', params.RELEASE_VERSION, + '--base', 'main', + '--push' + ] + if (params.DRY_RUN) branchArgs << '--dry-run' + + sh """#!/usr/bin/env bash + set -euo pipefail + git config user.email "[email protected]" + git config user.name "Apache KIE Release Bot" + git config --local credential.helper '!f() { echo username=\$GITHUB_USER; echo password=\$GITHUB_TOKEN; }; f' + chmod +x script/release/*.sh + ${branchArgs.collect { "'${it.replace("'", "'\\''")}'" }.join(' ')} + """ + } + } + } + } + + stage('Execute Release Scripts') { + steps { + // The Maven settings id is a Config File Provider id (not a secret) and is + // exposed as MAVEN_SETTINGS_FILE. GPG key/passphrase and the GitHub push + // credential are real credentials and use withCredentials. + script { + def creds = [ + file(credentialsId: params.GPG_KEY_CREDS_ID, variable: 'GPG_KEY_FILE_PATH'), + usernamePassword(credentialsId: params.GIT_PUSH_CREDS_ID, usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN') + ] + // Passphrase is optional: the KIE release signing key has none. + if (params.GPG_PASSPHRASE_CREDS_ID?.trim()) { + creds << string(credentialsId: params.GPG_PASSPHRASE_CREDS_ID, variable: 'MAVEN_GPG_PASSPHRASE') + } + configFileProvider([configFile(fileId: params.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) { + withCredentials(creds) { + // Import the signing key so the apache-release profile can sign + // artifacts. Passphrase is supplied later via MAVEN_GPG_PASSPHRASE. + sh '''#!/usr/bin/env bash + set -euo pipefail + gpg --batch --pinentry-mode=loopback --import "$GPG_KEY_FILE_PATH" + ''' + + // Configure Git identity for the R commit and authenticate the + // raw `git push` in 02-rc-commit.sh. The credential helper reads + // the token from the environment at push time, never from disk. + sh """#!/usr/bin/env bash + set -euo pipefail + git config user.email "[email protected]" + git config user.name "Apache KIE Release Bot" + git config --local credential.helper '!f() { echo username=\$GITHUB_USER; echo password=\$GITHUB_TOKEN; }; f' + """ + + // Build the argv array safely — each parameter is a + // separate shell word, no string concatenation or eval. + def releaseArgs = [ + './script/release/release-all.sh', + '--version', params.RELEASE_VERSION, + '--tag', params.TAG_NAME + ] + if (params.SKIP_TESTS) releaseArgs << '--skip-tests' + if (params.DEPLOY) releaseArgs << '--deploy' + if (params.STAGING_URL?.trim()) releaseArgs += ['--staging-url', params.STAGING_URL.trim()] + if (params.PUSH_TAG) releaseArgs << '--push-tag' + if (params.EXTRA_MAVEN_OPTS?.trim()) releaseArgs += ['--maven-opts', params.EXTRA_MAVEN_OPTS.trim()] + if (params.DRY_RUN) releaseArgs << '--dry-run' + + // MAVEN_SETTINGS_FILE is injected by configFileProvider above. + // If a passphrase credential was given, MAVEN_GPG_PASSPHRASE is in + // env and read by the GPG plugin directly (not a CLI arg). + withEnv(["MAVEN_SETTINGS=${MAVEN_SETTINGS_FILE}"]) { + sh """#!/usr/bin/env bash + set -euo pipefail + chmod +x script/release/*.sh + ${releaseArgs.collect { "'${it.replace("'", "'\\''")}'" }.join(' ')} Review Comment: When CREATE_STREAM_BRANCH is false (the default), nothing checks out the stream branch before this invocation. The RC is therefore created from the job's implicit SCM checkout: a job loading this Jenkinsfile from main will tag and stage main even for a 10.3.x release, because 02-rc-commit.sh only warns about the mismatch. Fetch and check out the stream derived from RELEASE_VERSION, or reject an unexpected checkout before creating the RC. ########## .ci/jenkins/Jenkinsfile.103xplus.release-promote: ########## @@ -0,0 +1,139 @@ +/* + * 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. + */ + +// 10.3.x+ promote / tag-release pipeline for incubator-kie. +// Run after the IPMC vote passes to: +// 1. Create and push the official release Git tag (e.g. 10.3.0) pointing to the approved RC commit. +// 2. Create the GitHub Release for incubator-kie. + +pipeline { + agent { + label 'ubuntu' + } + + tools { + maven 'maven_3.9.16' + jdk 'jdk_17_latest' + } + + options { + timestamps() + timeout(time: 60, unit: 'MINUTES') + } + + parameters { + string(name: 'PROJECT_VERSION', defaultValue: '', description: 'Release version (e.g. 10.3.0)', trim: true) + string(name: 'GIT_TAG', defaultValue: '', description: 'Approved RC tag (e.g. 10.3.0-rc1)', trim: true) + string(name: 'BUILD_BRANCH_NAME', defaultValue: '', description: 'Stream branch name (e.g. 10.3.x)', trim: true) + string(name: 'GIT_AUTHOR_PUSH_CREDS_ID', defaultValue: '84811880-2025-45b6-a44c-2f33bef30ad2', description: 'GitHub push credentials ID', trim: true) + } + + stages { + stage('Initialization') { + steps { + script { + cleanWs() + + assert params.PROJECT_VERSION : 'PROJECT_VERSION is required (e.g. 10.3.0)' + assert params.GIT_TAG : 'GIT_TAG (approved RC tag, e.g. 10.3.0-rc1) is required' Review Comment: With PROJECT_VERSION=10.3.1 and GIT_TAG=10.3.0-rc1, the tagging stage pushes 10.3.0, but the GitHub-release stage requests 10.3.1. Because `gh release create` supplies `--target` without `--verify-tag`, it can create the missing tag at the development branch tip and publish unapproved code. Require GIT_TAG to be an RC tag for PROJECT_VERSION before making any remote changes. ########## script/release/04-deploy-to-staging.sh: ########## @@ -0,0 +1,179 @@ +#!/usr/bin/env bash +# +# 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. +# + +set -euo pipefail + +# Deploys the locally-built JARs (already in ~/.m2) to a Nexus staging +# repository for Apache release voting. +# +# By default this script runs in DRY RUN mode and will NOT push anything +# remotely. Pass --deploy to actually upload to Nexus. +# +# Usage: +# ./script/release/04-deploy-to-staging.sh --tag <rc-tag> [--deploy] [--staging-url <url>] +# +# Examples: +# # dry run (safe — prints the Maven command that would be run) +# ./script/release/04-deploy-to-staging.sh --tag 10.3.0-rc1 +# +# # actually deploy to Apache Nexus staging +# ./script/release/04-deploy-to-staging.sh --tag 10.3.0-rc1 --deploy +# +# # deploy to a custom staging URL +# ./script/release/04-deploy-to-staging.sh --tag 10.3.0-rc1 --deploy \ +# --staging-url https://repository.apache.org/service/local/staging/deploy/maven2 +# +# Environment variables consumed when --deploy is active: +# MAVEN_SETTINGS Path to a settings.xml with Nexus credentials (required). +# The settings file must define a server with id "apache.releases.https" +# (or the id set via --server-id) carrying the deployer credentials. +# MAVEN_GPG_PASSPHRASE GPG passphrase for signing (required for Apache releases). +# Passed to the GPG agent via the gpg-agent pinentry loopback +# mechanism; NOT exposed on the Maven command line. + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" + +TAG_NAME="" +DEPLOY=false +STAGING_URL="https://repository.apache.org/service/local/staging/deploy/maven2" +SERVER_ID="apache.releases.https" + +while [[ $# -gt 0 ]]; do + case $1 in + --tag) + TAG_NAME="${2:-}" + shift 2 + ;; + --deploy) + DEPLOY=true + shift + ;; + --staging-url) + STAGING_URL="${2:-}" + shift 2 + ;; + --server-id) + SERVER_ID="${2:-}" + shift 2 + ;; + *) + echo "Unknown option: $1" + echo "Usage: $0 --tag <rc-tag> [--deploy] [--staging-url <url>] [--server-id <id>]" + exit 1 + ;; + esac +done + +if [[ -z "${TAG_NAME}" ]]; then + echo "ERROR: --tag is required." + echo "Usage: $0 --tag 10.3.0-rc1 [--deploy]" + exit 1 +fi + +cd "${REPO_ROOT}" + +# ── Resolve the version from the tag name ──────────────────────────────────── +# Tag format: <version>-rc<N> (e.g. 10.3.0-rc1) +RELEASE_VERSION="$(echo "${TAG_NAME}" | sed 's/-rc[0-9]*$//')" + +echo "========================================" +echo "Apache KIE repo — deploy to staging" +echo "Tag : ${TAG_NAME}" +echo "Release version : ${RELEASE_VERSION}" +echo "Staging URL : ${STAGING_URL}" +echo "Server ID : ${SERVER_ID}" +echo "Deploy (real) : ${DEPLOY}" +echo "========================================" + +# ── Verify we are on / can resolve the RC tag ──────────────────────────────── +if ! git rev-parse "${TAG_NAME}" &>/dev/null; then + echo "" + echo "ERROR: Git tag '${TAG_NAME}' not found in this repository." + echo " Run rc-commit.sh first, or check out the tag manually." + exit 1 +fi + +# ── Assemble Maven flags ───────────────────────────────────────────────────── + +DEPLOY_MVN_FLAGS=( + "-DskipTests" + "-Dfull" + # Activate the apache-release profile so the source/javadoc and GPG-signing + # goals defined there are executed (required for Apache releases). + "-Papache-release" + "-DaltDeploymentRepository=${SERVER_ID}::default::${STAGING_URL}" +) + +if [[ -n "${MAVEN_SETTINGS:-}" ]]; then + DEPLOY_MVN_FLAGS+=("-s" "${MAVEN_SETTINGS}") +fi + +# NOTE: MAVEN_GPG_PASSPHRASE is intentionally NOT added to the Maven command +# line — exposing it there would print it in captured console logs. +# The standard GPG Maven plugin (version 3+) reads the passphrase from the +# environment variable MAVEN_GPG_PASSPHRASE via pinentry-loopback automatically. +# For older plugin versions, configure loopback in ~/.gnupg/gpg-agent.conf: +# allow-loopback-pinentry +# and pass: -Dgpg.useagent=false -Dgpg.loopback=true in MAVEN_SETTINGS. + +echo "" +if [[ "${DEPLOY}" == "false" ]]; then + echo "[DRY RUN] Would run from tag ${TAG_NAME}:" + echo "" + echo " git checkout ${TAG_NAME}" + echo " mvn deploy ${DEPLOY_MVN_FLAGS[*]}" + echo " git checkout -" + echo "" + echo "Pass --deploy to actually upload artifacts." + exit 0 +fi + +# ── Checkout the exact tag commit before deploying ─────────────────────────── +# Save the original ref as the commit SHA when in detached HEAD state (e.g., +# Jenkins SCM checkout). `git rev-parse --abbrev-ref HEAD` returns "HEAD" when +# detached, which cannot be used to restore the checkout afterwards. +if git symbolic-ref --quiet HEAD &>/dev/null; then + ORIG_REF="$(git rev-parse --abbrev-ref HEAD)" +else + ORIG_REF="$(git rev-parse HEAD)" +fi + +echo "--- Checking out tag ${TAG_NAME} ---" +git checkout "${TAG_NAME}" Review Comment: Checking out the tag does not guarantee a clean release tree: Git preserves local edits when they do not conflict with the checkout, including when HEAD is already at this tag. Running this standalone script with an edited Java source can therefore sign and deploy artifacts that do not match the RC commit. Reject staged, unstaged and untracked changes before checkout, as `02-rc-commit.sh` already does. ########## .ci/ci-image/wait-for-docker.sh: ########## @@ -0,0 +1,4 @@ +#!/bin/bash +source wait-for-process.sh + +wait_for_process dockerd Review Comment: This only waits for dockerd to have a PID, not for its socket/API to be ready. On a slow cold start it can return while the daemon is still initializing, so start-docker.sh's chown and the image smoke test's docker info can fail even though Docker subsequently starts successfully. Use a bounded daemon API readiness probe and synchronize the socket setup before allowing callers to proceed. ########## .ci/jenkins/Jenkinsfile.103xplus.release-promote: ########## @@ -0,0 +1,139 @@ +/* + * 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. + */ + +// 10.3.x+ promote / tag-release pipeline for incubator-kie. +// Run after the IPMC vote passes to: +// 1. Create and push the official release Git tag (e.g. 10.3.0) pointing to the approved RC commit. +// 2. Create the GitHub Release for incubator-kie. + +pipeline { + agent { + label 'ubuntu' + } + + tools { + maven 'maven_3.9.16' + jdk 'jdk_17_latest' + } + + options { + timestamps() + timeout(time: 60, unit: 'MINUTES') + } + + parameters { + string(name: 'PROJECT_VERSION', defaultValue: '', description: 'Release version (e.g. 10.3.0)', trim: true) + string(name: 'GIT_TAG', defaultValue: '', description: 'Approved RC tag (e.g. 10.3.0-rc1)', trim: true) + string(name: 'BUILD_BRANCH_NAME', defaultValue: '', description: 'Stream branch name (e.g. 10.3.x)', trim: true) + string(name: 'GIT_AUTHOR_PUSH_CREDS_ID', defaultValue: '84811880-2025-45b6-a44c-2f33bef30ad2', description: 'GitHub push credentials ID', trim: true) + } + + stages { + stage('Initialization') { + steps { + script { + cleanWs() + + assert params.PROJECT_VERSION : 'PROJECT_VERSION is required (e.g. 10.3.0)' + assert params.GIT_TAG : 'GIT_TAG (approved RC tag, e.g. 10.3.0-rc1) is required' + assert params.BUILD_BRANCH_NAME : 'BUILD_BRANCH_NAME (e.g. 10.3.x) is required' + + currentBuild.displayName = "${params.PROJECT_VERSION} (${params.GIT_TAG})" + } + } + } + + stage('Checkout repository') { + steps { + script { + dir('incubator-kie') { + checkout([$class: 'GitSCM', + branches: [[name: "*/${params.BUILD_BRANCH_NAME}"]], + userRemoteConfigs: [[ + url: 'https://github.com/apache/incubator-kie.git', + credentialsId: params.GIT_AUTHOR_PUSH_CREDS_ID + ]] + ]) + } + } + } + } + + stage('Tag final release') { + steps { + dir('incubator-kie') { + withCredentials([ + usernamePassword(credentialsId: params.GIT_AUTHOR_PUSH_CREDS_ID, usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN') + ]) { + sh """#!/usr/bin/env bash + set -euo pipefail + git config user.email "[email protected]" + git config user.name "Apache KIE Release Bot" + git config --local credential.helper '!f() { echo username=\$GITHUB_USER; echo password=\$GITHUB_TOKEN; }; f' + + # Fetch the approved RC tag + git fetch origin "refs/tags/${params.GIT_TAG}:refs/tags/${params.GIT_TAG}" + + # Create and push the final release tag + chmod +x script/release/05-tag-release.sh + ./script/release/05-tag-release.sh --rc-tag "${params.GIT_TAG}" --push + """ + } + } + } + } + + stage('Create GitHub Release') { + steps { + dir('incubator-kie') { + withCredentials([ + usernamePassword(credentialsId: params.GIT_AUTHOR_PUSH_CREDS_ID, usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN') + ]) { + sh """#!/usr/bin/env bash + set -euo pipefail + git config --local credential.helper '!f() { echo username=\$GITHUB_USER; echo password=\$GITHUB_TOKEN; }; f' + + FINAL_TAG="${params.PROJECT_VERSION}" + + # Delete any pre-existing release for this tag if needed + if gh release view "\${FINAL_TAG}" --repo "apache/incubator-kie" &>/dev/null; then + gh release delete "\${FINAL_TAG}" --repo "apache/incubator-kie" --yes + fi + + PREV_TAG="\$(git tag --sort=-version:refname | grep -v "^\${FINAL_TAG}\$" | head -1 || true)" Review Comment: The fetched RC tag is included in this search. For a normal 10.3.0 promotion, the selected tag will be 10.3.0-rc1 rather than the previous final release; the RC and final tag resolve to the same commit, so --notes-start-tag produces an empty release changelog. Select the preceding final release tag, excluding RC tags and tags from later release streams. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
