Skip to content

Commit

Permalink
Merge branch 'main' into incubator-kie-issues-1131-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhitocode authored May 24, 2024
2 parents 2ab14e0 + 7f04f1f commit cf5ddf2
Show file tree
Hide file tree
Showing 116 changed files with 2,763 additions and 520 deletions.
96 changes: 10 additions & 86 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.jenkinsci.plugins.workflow.libs.Library
@Library('jenkins-pipeline-shared-libraries')_

import org.kie.jenkins.MavenCommand
import org.kie.jenkins.MavenStagingHelper

deployProperties = [:]

Expand Down Expand Up @@ -49,7 +48,6 @@ pipeline {
KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

PR_BRANCH_HASH = "${util.generateHash(10)}"
MAVEN_DEPLOY_LOCAL_DIR = "/tmp/maven_deploy_dir"
}

stages {
Expand Down Expand Up @@ -136,10 +134,16 @@ pipeline {
}
}
}
stage('Build & Test') {
stage('Deploy kogito-runtimes') {
steps {
script {
dir(getRepoName()) {
withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) {
def installOrDeploy
if (shouldDeployToRepository()) {
installOrDeploy = "deploy -DdeployAtEnd -Dapache.repository.username=${REPOSITORY_USER} -Dapache.repository.password=${REPOSITORY_TOKEN} -DretryFailedDeploymentCount=5"
} else {
installOrDeploy = 'install'
}
def mvnCmd = getMavenCommand()
.withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : [])
.withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ? [ env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ] : [])
Expand All @@ -151,7 +155,7 @@ pipeline {
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
mvnCmd
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.run('clean install')
.run("clean $installOrDeploy")
}
}
}
Expand All @@ -165,37 +169,6 @@ pipeline {
}
}
}
stage('Deploy locally') {
steps {
script {
dir(getRepoName()) {
runMavenDeploy(true)
}
}
}
}
stage('Upload artifacts to given repository') {
when {
expression { return !isRelease() && shouldDeployToRepository() }
}
steps {
script {
// Deploy to specific repository with credentials
maven.uploadLocalArtifacts(env.MAVEN_REPO_CREDS_ID, getLocalDeploymentFolder(), getMavenRepoZipUrl())
}
}
}
stage('Stage artifacts') {
when {
expression { return shouldStageArtifacts() }
}
steps {
script {
// Stage release artifacts
runMavenStage()
}
}
}
stage('Create PR') {
when {
expression { return isRelease() || isCreatePr() }
Expand Down Expand Up @@ -268,14 +241,6 @@ void sendNotification() {
}
}

boolean isSpecificArtifactsUpload() {
return env.MAVEN_DEPLOY_REPOSITORY && env.MAVEN_REPO_CREDS_ID
}

boolean shouldStageArtifacts() {
return isRelease()
}

boolean shouldDeployToRepository() {
return env.MAVEN_DEPLOY_REPOSITORY && env.MAVEN_REPO_CREDS_ID && getGitAuthor() == 'apache'
}
Expand Down Expand Up @@ -335,51 +300,10 @@ MavenCommand getMavenCommand(String directory = '') {
.withProperty('full')
}

void runMavenDeploy(boolean localDeployment = false) {
mvnCmd = getMavenCommand()
.withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ? [ env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ] : [])
.withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : [])

if (localDeployment) {
mvnCmd.withLocalDeployFolder(getLocalDeploymentFolder())
} else if (env.MAVEN_DEPLOY_REPOSITORY) {
mvnCmd.withDeployRepository(env.MAVEN_DEPLOY_REPOSITORY)
}

configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
mvnCmd
.skipTests(true)
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.run('clean deploy')
}
}

String getMavenRepoZipUrl() {
return "${env.MAVEN_DEPLOY_REPOSITORY.replaceAll('/content/', '/service/local/').replaceFirst('/*$', '')}/content-compressed"
}

void runMavenStage() {
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
MavenStagingHelper stagingHelper = getStagingHelper(getMavenCommand().withSettingsXmlFile(MAVEN_SETTINGS_FILE))
deployProperties.putAll(stagingHelper.stageLocalArtifacts(env.NEXUS_STAGING_PROFILE_ID, getLocalDeploymentFolder()))
stagingHelper.promoteStagingRepository(env.NEXUS_BUILD_PROMOTION_PROFILE_ID)
}
}

MavenStagingHelper getStagingHelper(MavenCommand mavenCommand) {
return new MavenStagingHelper(this, mavenCommand)
.withNexusReleaseUrl(env.NEXUS_RELEASE_URL)
.withNexusReleaseRepositoryId(env.NEXUS_RELEASE_REPOSITORY_ID)
}

String getLocalDeploymentFolder() {
return "${env.MAVEN_DEPLOY_LOCAL_DIR}/${getRepoName()}"
}

String getWorkflowCommonDeploymentPath() {
return "${getRepoName()}/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment"
}

String getDataIndexEphemeralReleaseImage() {
return "quay.io/kiegroup/kogito-data-index-ephemeral:${util.getMajorMinorVersion(getProjectVersion())}"
return "docker.io/apache/incubator-kie-kogito-data-index-ephemeral:${util.getMajorMinorVersion(getProjectVersion())}"
}
16 changes: 8 additions & 8 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ pipeline {
steps {
script {
dir(getRepoName()) {
approveAndMergePR(getDeployPrLink())
checkoutRepo()
mergeAndPush(getDeployPrLink())
tagLatest()
}
}
Expand All @@ -78,10 +78,10 @@ pipeline {
dir(getRepoName()) {
checkoutRepo()
if(githubscm.isReleaseExist(getGitTag(), getGitAuthorCredsId())) {
githubscm.deleteRelease(getGitTag(), getGitAuthorCredsId())
githubscm.deleteRelease(getGitTag(), getGitAuthorPushCredsId())
}
githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTagFromVersion(getGitTag()), getGitAuthorCredsId())
githubscm.updateReleaseBody(getGitTag(), getGitAuthorCredsId())
githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTagFromVersion(getGitTag()), getGitAuthorPushCredsId())
githubscm.updateReleaseBody(getGitTag(), getGitAuthorPushCredsId())
}
}
}
Expand Down Expand Up @@ -201,10 +201,10 @@ void checkoutRepo() {
sh "git checkout ${getBuildBranch()}"
}

void mergeAndPush(String prLink) {
if (prLink) {
githubscm.mergePR(prLink, getGitAuthorCredsId())
githubscm.pushObject('origin', getBuildBranch(), getGitAuthorPushCredsId())
void approveAndMergePR(String prLink) {
if (prLink?.trim()) {
githubscm.approvePR(prLink, getGitAuthorPushCredsId())
githubscm.mergePR(prLink, getGitAuthorPushCredsId())
}
}

Expand Down
28 changes: 6 additions & 22 deletions .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.jenkinsci.plugins.workflow.libs.Library
import org.kie.jenkins.MavenCommand

droolsRepo = 'incubator-kie-drools'
dataIndexEphemeralImageName = 'quay.io/kiegroup/kogito-data-index-ephemeral'

pipeline {
agent {
Expand Down Expand Up @@ -53,7 +52,7 @@ pipeline {
currentBuild.displayName = params.DISPLAY_NAME
}

checkoutRepo(droolsRepo, getDroolsTargetBranch())
checkoutRepo(droolsRepo, getBuildBranch())
checkoutRepo(getRepoName(), getBuildBranch())
}
}
Expand Down Expand Up @@ -98,8 +97,8 @@ pipeline {
getMavenCommand(getRepoName())
.withOptions(['-pl :kogito-quarkus-workflow-common-deployment'])
.withSettingsXmlFile(MAVEN_SETTINGS_FILE),
'data-index-ephemeral.image',
getDataIndexEphemeralImage()
'data-index-ephemeral.image.tagVersion',
getDataIndexEphemeralImageTagVersion()
)
}
}
Expand Down Expand Up @@ -151,18 +150,6 @@ void checkoutRepo(String repository, String branch) {
}
}

String getDroolsTargetBranch() {
String targetBranch = getBuildBranch()
List versionSplit = targetBranch.split("\\.") as List

if (versionSplit[0].isNumber()) {
targetBranch = "${Integer.parseInt(versionSplit[0]) + 7}.${versionSplit.tail().join('.')}"
} else {
echo "Cannot parse targetBranch as release branch so going further with current value: ${targetBranch}"
}
return targetBranch
}

String getRepoName() {
return env.REPO_NAME
}
Expand Down Expand Up @@ -211,13 +198,10 @@ String getWorkflowCommonDeploymentRelativePath() {
return 'quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment'
}

String getDataIndexEphemeralImage() {
if (isMainBranch()) {
return "${dataIndexEphemeralImageName}-nightly:latest"
}
String getDataIndexEphemeralImageTagVersion() {
String version = getKogitoVersion()
if (version.endsWith('-SNAPSHOT')) {
return "${dataIndexEphemeralImageName}-nightly:${util.getMajorMinorVersion(version)}"
return getBuildBranch() // E.g., `main` or `10.0.x`
}
return "${dataIndexEphemeralImageName}:${util.getMajorMinorVersion(version)}"
return util.getMajorMinorVersion(version) // E.g., `10.0`
}
58 changes: 20 additions & 38 deletions .ci/jenkins/Jenkinsfile.weekly.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,28 @@ pipeline {
}
}

stage('Build & Test & Deploy locally') {
stage('Build & Test & Install/Deploy') {
steps {
script {
runMavenLocalDeploy(params.SKIP_TESTS)
withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) {
def installOrDeploy
if (shouldDeployToRepository()) {
installOrDeploy = "deploy -DdeployAtEnd -Dapache.repository.username=${REPOSITORY_USER} -Dapache.repository.password=${REPOSITORY_TOKEN} -DretryFailedDeploymentCount=5"
} else {
installOrDeploy = 'install'
}
def mvnCmd = getMavenCommand().withProperty('maven.test.failure.ignore', true)
.withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : [])
.withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ? [ env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ] : [])
if (params.SKIP_TESTS) {
mvnCmd.skipTests() // Conflict somehow with Python testing. If `skipTests={anyvalue}` is set, then exec plugin is not executed ...
}
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
mvnCmd
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.run("clean $installOrDeploy")
}
}
}
}
post {
Expand All @@ -117,28 +135,6 @@ pipeline {
}
}

stage('Upload artifacts to given repository') {
when {
expression { return shouldDeployToRepository() }
}
steps {
script {
withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) {
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
getMavenCommand()
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.withProperty('wagon.source', "file://${getLocalDeploymentFolder()}")
.withProperty('wagon.target', env.MAVEN_DEPLOY_REPOSITORY)
.withProperty('wagon.targetId', 'apache-snapshots-repository')
.withProperty('apache.snapshot.repository.username', REPOSITORY_USER)
.withProperty('apache.snapshot.repository.password', REPOSITORY_TOKEN)
.run("org.codehaus.mojo:wagon-maven-plugin:2.0.2:merge-maven-repos")
}
}
}
}
}

stage('Create and push a new tag') {
steps {
script {
Expand Down Expand Up @@ -237,20 +233,6 @@ MavenCommand getMavenCommand(String directory = '') {
.withProperty('full')
}

void runMavenLocalDeploy(boolean skipTests = true) {
mvnCmd = getMavenCommand()
mvnCmd.withLocalDeployFolder(getLocalDeploymentFolder())

configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
mvnCmd.withProperty('maven.test.failure.ignore', true)
.withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : [])
.withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ? [ env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ] : [])
//.skipTests(skipTests) // Conflict somehow with Python testing. If `skipTests={anyvalue}` is set, then exec plugin is not executed ...
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.run('clean deploy')
}
}

String getLocalDeploymentFolder() {
return "${env.MAVEN_DEPLOY_LOCAL_DIR}/${getRepoName()}"
}
Expand Down
5 changes: 0 additions & 5 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,6 @@ void setupReleaseDeployJob() {
MAVEN_DEPENDENCIES_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
MAVEN_DEPLOY_REPOSITORY: "${MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_URL}",
MAVEN_REPO_CREDS_ID: "${MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_CREDS_ID}",

NEXUS_RELEASE_URL: "${MAVEN_NEXUS_RELEASE_URL}",
NEXUS_RELEASE_REPOSITORY_ID: "${MAVEN_NEXUS_RELEASE_REPOSITORY}",
NEXUS_STAGING_PROFILE_ID: "${MAVEN_NEXUS_STAGING_PROFILE_ID}",
NEXUS_BUILD_PROMOTION_PROFILE_ID: "${MAVEN_NEXUS_BUILD_PROMOTION_PROFILE_ID}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.jbpm.process.core.context.variable.Variable;
import org.jbpm.process.core.context.variable.VariableScope;
import org.jbpm.process.core.validation.ProcessValidationError;
import org.jbpm.process.instance.impl.FeelErrorEvaluatorListener;
import org.jbpm.process.instance.impl.FeelReturnValueEvaluator;
import org.jbpm.ruleflow.core.RuleFlowProcess;
import org.jbpm.ruleflow.core.validation.RuleFlowProcessValidator;
import org.jbpm.workflow.core.Constraint;
Expand All @@ -36,6 +38,7 @@
import org.kie.api.definition.process.Node;
import org.kie.dmn.feel.FEEL;
import org.kie.dmn.feel.lang.CompilerContext;
import org.kie.dmn.feel.lang.impl.FEELBuilder;
import org.kie.dmn.feel.parser.feel11.profiles.KieExtendedFEELProfile;

import static java.lang.String.format;
Expand Down Expand Up @@ -87,7 +90,7 @@ protected void validateNodes(Node[] nodes, List<ProcessValidationError> errors,
* use the FEEL compiler capabilities to verify if mere compilation of the FEEL expression may contain any error.
*/
private void verifyFEELbyCompilingExpression(VariableScope variableScope, String feelExpression) {
FEEL feel = FEEL.newInstance(Collections.singletonList(new KieExtendedFEELProfile()));
FEEL feel = FEELBuilder.builder().withProfiles(Collections.singletonList(new KieExtendedFEELProfile())).build();
FeelErrorEvaluatorListener feelErrorListener = new FeelErrorEvaluatorListener();
feel.addListener(feelErrorListener);
CompilerContext cc = feel.newCompilerContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.drools.drl.ast.descr.ReturnValueDescr;
import org.jbpm.process.builder.ReturnValueEvaluatorBuilder;
import org.jbpm.process.core.ContextResolver;
import org.jbpm.process.instance.impl.FeelReturnValueEvaluator;
import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator;

public class FeelReturnValueEvaluatorBuilder implements ReturnValueEvaluatorBuilder {
Expand Down
Loading

0 comments on commit cf5ddf2

Please sign in to comment.