| @Library('jenkins-pipeline-shared-libraries')_ |
| |
| helper = null |
| testsFailed = false |
| |
| pipeline { |
| agent { |
| docker { |
| image env.AGENT_DOCKER_BUILDER_IMAGE |
| args env.AGENT_DOCKER_BUILDER_ARGS |
| label util.avoidFaultyNodes() |
| } |
| } |
| |
| options { |
| timeout(time: 120, unit: 'HOURS') |
| timestamps() |
| } |
| |
| environment { |
| KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") |
| } |
| |
| stages { |
| stage('Setup pipeline') { |
| steps { |
| script { |
| helper = load '.ci/jenkins/scripts/helper.groovy' |
| helper.initPipeline() |
| } |
| } |
| } |
| stage('Initialize') { |
| steps { |
| script { |
| helper.cleanGoPath() |
| |
| helper.updateDisplayName() |
| helper.checkoutRepo() |
| } |
| } |
| } |
| |
| stage('Update version') { |
| steps { |
| script { |
| sh "make bump-version new_version=${helper.getProjectVersion()}" |
| } |
| } |
| } |
| |
| stage('Clean release notes') { |
| when { |
| expression { isMainBranch() } |
| } |
| steps { |
| script { |
| String releaseNotesFilename = 'RELEASE_NOTES.md' |
| sh "rm -rf ${releaseNotesFilename}" |
| writeFile(file: releaseNotesFilename, text: getCleanedReleaseNotes()) |
| } |
| } |
| } |
| |
| stage('Update branch') { |
| steps { |
| script { |
| sh ''' |
| git checkout -- go.mod |
| git checkout -- go.sum |
| ''' |
| if (githubscm.isThereAnyChanges()) { |
| githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId()) |
| githubscm.commitChanges("[${helper.getBuildBranch()}] Update version to ${helper.getProjectVersion()}", { |
| sh ''' |
| git add . |
| ''' |
| }) |
| githubscm.pushObject('origin', helper.getBuildBranch(), helper.getGitAuthorPushCredsId()) |
| } else { |
| println '[WARN] no changes to commit' |
| } |
| } |
| } |
| } |
| } |
| post { |
| unsuccessful { |
| sendNotification() |
| } |
| cleanup { |
| script { |
| helper.cleanGoPath() |
| util.cleanNode(containerEngine) |
| } |
| } |
| } |
| } |
| |
| void sendNotification() { |
| if (params.SEND_NOTIFICATION) { |
| mailer.sendMarkdownTestSummaryNotification('Setup branch', "[${helper.getBuildBranch()}] Kogito Serverless Operator", [env.KOGITO_CI_EMAIL_TO], "You can find test error logs here: ${BUILD_URL}/artifact/test/logs/error/") |
| } else { |
| echo 'No notification sent per configuration' |
| } |
| } |
| |
| boolean isMainBranch() { |
| return env.IS_MAIN_BRANCH?.toBoolean() |
| } |
| |
| String getCleanedReleaseNotes() { |
| return ''' |
| <!-- Keep them in alphabetical order --> |
| ## Enhancements |
| |
| ## Bug Fixes |
| |
| ## Known Issues |
| |
| ''' |
| } |