-
Couldn't load subscription status.
- Fork 4
MLE-24593 Add publishing step and enable scheduled builds #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vitalykorolev
merged 3 commits into
marklogic:release/1.1.0
from
vitalykorolev:MLE-24593_add-docker-push
Oct 24, 2025
+75
−22
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,12 @@ import groovy.json.JsonSlurperClassic | |
| emailList = '[email protected], [email protected], [email protected], [email protected], [email protected]' | ||
| emailSecList = '[email protected]' | ||
| gitCredID = 'marklogic-builder-github' | ||
| operatorRegistry = 'ml-marklogic-operator-dev.bed-artifactory.bedford.progress.com' | ||
| JIRA_ID = '' | ||
| JIRA_ID_PATTERN = /(?i)(MLE)-\d{3,6}/ | ||
| operatorRepo = 'marklogic-kubernetes-operator' | ||
| timeStamp = new Date().format('yyyyMMdd') | ||
| branchNameTag = env.BRANCH_NAME.replaceAll('/', '-') | ||
|
|
||
| // Define local funtions | ||
| void preBuildCheck() { | ||
|
|
@@ -126,15 +130,15 @@ void runTests() { | |
| } | ||
|
|
||
| void runMinikubeSetup() { | ||
| sh ''' | ||
| make e2e-setup-minikube | ||
| ''' | ||
| sh """ | ||
| make e2e-setup-minikube IMG=${operatorRepo}:${VERSION} | ||
| """ | ||
| } | ||
|
|
||
| void runE2eTests() { | ||
| sh ''' | ||
| make e2e-test | ||
| ''' | ||
| sh """ | ||
| make e2e-test IMG=${operatorRepo}:${VERSION} | ||
| """ | ||
| } | ||
|
|
||
| void runMinikubeCleanup() { | ||
|
|
@@ -143,9 +147,43 @@ void runMinikubeCleanup() { | |
| ''' | ||
| } | ||
|
|
||
| void runSecurityScan() { | ||
| build job: 'securityscans/Blackduck/KubeNinjas/kubernetes-operator', wait: false, parameters: [ string(name: 'branch', value: "${env.BRANCH_NAME}") ] | ||
| void runBlackDuckScan() { | ||
| // Trigger BlackDuck scan job with CONTAINER_IMAGES parameter when params.PUBLISH_IMAGE is true | ||
| if (params.PUBLISH_IMAGE) { | ||
| build job: 'securityscans/Blackduck/KubeNinjas/kubernetes-operator', wait: false, parameters: [ string(name: 'branch', value: "${env.BRANCH_NAME}"), string(name: 'CONTAINER_IMAGES', value: "${operatorRepo}:${VERSION}-${branchNameTag}") ] | ||
| } else { | ||
| build job: 'securityscans/Blackduck/KubeNinjas/kubernetes-operator', wait: false, parameters: [ string(name: 'branch', value: "${env.BRANCH_NAME}") ] | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Publishes the built Docker image to the internal Artifactory registry. | ||
| * Tags the image with multiple tags (version-specific, branch-specific, latest). | ||
| * Requires Artifactory credentials. | ||
| */ | ||
| void publishToInternalRegistry() { | ||
| withCredentials([usernamePassword(credentialsId: 'builder-credentials-artifactory', passwordVariable: 'docker_password', usernameVariable: 'docker_user')]) { | ||
|
|
||
| sh """ | ||
| # make sure to logout first to avoid issues with cached credentials | ||
| docker logout ${operatorRegistry} | ||
| echo "${docker_password}" | docker login --username ${docker_user} --password-stdin ${operatorRegistry} | ||
|
|
||
| # Create tags | ||
| docker tag ${operatorRepo}:${VERSION} ${operatorRegistry}/${operatorRepo}:${VERSION} | ||
| docker tag ${operatorRepo}:${VERSION} ${operatorRegistry}/${operatorRepo}:${VERSION}-${branchNameTag} | ||
| docker tag ${operatorRepo}:${VERSION} ${operatorRegistry}/${operatorRepo}:${VERSION}-${branchNameTag}-${timeStamp} | ||
| docker tag ${operatorRepo}:${VERSION} ${operatorRegistry}/${operatorRepo}:latest | ||
|
|
||
| # Push images to internal registry | ||
| docker push ${operatorRegistry}/${operatorRepo}:${VERSION} | ||
| docker push ${operatorRegistry}/${operatorRepo}:${VERSION}-${branchNameTag} | ||
| docker push ${operatorRegistry}/${operatorRepo}:${VERSION}-${branchNameTag}-${timeStamp} | ||
| docker push ${operatorRegistry}/${operatorRepo}:latest | ||
| """ | ||
| } | ||
vitalykorolev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| pipeline { | ||
| agent { | ||
| label { | ||
|
|
@@ -157,16 +195,17 @@ pipeline { | |
| buildDiscarder logRotator(artifactDaysToKeepStr: '20', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '') | ||
| skipStagesAfterUnstable() | ||
| } | ||
| // triggers { | ||
| // //TODO: add scheduled runs | ||
| // } | ||
| // environment { | ||
| // //TODO | ||
| // } | ||
|
|
||
| triggers { | ||
| // Trigger nightly builds on the develop branch | ||
| parameterizedCron( env.BRANCH_NAME == 'develop' ? '''00 05 * * * % E2E_MARKLOGIC_IMAGE_VERSION=ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi-rootless:latest-12 | ||
vitalykorolev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 00 05 * * * % E2E_MARKLOGIC_IMAGE_VERSION=ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi-rootless:latest-11; PUBLISH_IMAGE=false''' : '') | ||
vitalykorolev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| parameters { | ||
| string(name: 'E2E_MARKLOGIC_IMAGE_VERSION', defaultValue: 'ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi-rootless:latest-12', description: 'Docker image to use for tests.', trim: true) | ||
| string(name: 'IMG', defaultValue: 'testrepo/marklogic-operator-image-dev:internal', description: 'Docker image for Running Operator Container', trim: true) | ||
| string(name: 'VERSION', defaultValue: '1.1.0', description: 'Version to tag the image with.', trim: true) | ||
vitalykorolev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| booleanParam(name: 'PUBLISH_IMAGE', defaultValue: false, description: 'Publish image to internal registry') | ||
| string(name: 'emailList', defaultValue: emailList, description: 'List of email for build notification', trim: true) | ||
| } | ||
|
|
||
|
|
@@ -177,12 +216,6 @@ pipeline { | |
| } | ||
| } | ||
|
|
||
| stage('Run-Security-Scan') { | ||
| steps { | ||
| runSecurityScan() | ||
| } | ||
| } | ||
|
|
||
| stage('Run-tests') { | ||
| steps { | ||
| runTests() | ||
|
|
@@ -206,6 +239,26 @@ pipeline { | |
| runMinikubeCleanup() | ||
| } | ||
| } | ||
|
|
||
| // Publish image to internal registries (conditional) | ||
| stage('Publish Image') { | ||
| when { | ||
| anyOf { | ||
| branch 'develop' | ||
| expression { return params.PUBLISH_IMAGE } | ||
| } | ||
| } | ||
| steps { | ||
| publishToInternalRegistry() | ||
| } | ||
| } | ||
|
|
||
| stage('Run-BlackDuck-Scan') { | ||
|
|
||
| steps { | ||
| runBlackDuckScan() | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.