@@ -8,8 +8,10 @@ import groovy.json.JsonSlurperClassic
8899emailSecList 
=  ' [email protected] ' 1010gitCredID =  ' marklogic-builder-github' 
11+ operatorRegistry =  ' ml-marklogic-operator-dev.bed-artifactory.bedford.progress.com' 
1112JIRA_ID  =  ' ' 
1213JIRA_ID_PATTERN  =  / (?i)(MLE)-\d {3,6}/ 
14+ operatorRepo =  ' marklogic-kubernetes-operator' 
1315
1416//  Define local funtions
1517void  preBuildCheck () {
@@ -126,15 +128,15 @@ void runTests() {
126128}
127129
128130void  runMinikubeSetup () {
129-     sh ''' 
130-         make e2e-setup-minikube 
131-     '''  
131+     sh """ 
132+         make e2e-setup-minikube IMG= ${ operatorRepo } : ${ VERSION }  
133+     """  
132134}
133135
134136void  runE2eTests () {
135-     sh ''' 
136-         make e2e-test 
137-     '''  
137+     sh """ 
138+         make e2e-test IMG= ${ operatorRepo } : ${ VERSION }  
139+     """  
138140}
139141
140142void  runMinikubeCleanup () {
@@ -146,6 +148,36 @@ void runMinikubeCleanup() {
146148void  runSecurityScan () {
147149    build job : ' securityscans/Blackduck/KubeNinjas/kubernetes-operator' wait : false , parameters : [ string(name : ' branch' value : " ${ env.BRANCH_NAME} " 
148150}
151+ 
152+ /** 
153+  * Publishes the built Docker image to the internal Artifactory registry. 
154+  * Tags the image with multiple tags (version-specific, branch-specific, latest). 
155+  * Requires Artifactory credentials. 
156+  */  
157+ void  publishToInternalRegistry () {
158+     withCredentials([usernamePassword(credentialsId : ' builder-credentials-artifactory' passwordVariable : ' docker_password' usernameVariable : ' docker_user' 
159+         timeStamp =  new  Date (). format(' yyyyMMdd' 
160+         branchNameTag =  env. BRANCH_NAME . replaceAll(' /' ' -' 
161+         sh """ 
162+             # make sure to logout first to avoid issues with cached credentials 
163+             docker logout ${ operatorRegistry}  
164+             echo "${ docker_password} ${ docker_user} ${ operatorRegistry}  
165+ 
166+             # Create tags 
167+             docker tag ${ operatorRepo} ${ VERSION} ${ operatorRegistry} ${ operatorRepo} ${ VERSION}  
168+             docker tag ${ operatorRepo} ${ VERSION} ${ operatorRegistry} ${ operatorRepo} ${ VERSION} ${ branchNameTag}  
169+             docker tag ${ operatorRepo} ${ VERSION} ${ operatorRegistry} ${ operatorRepo} ${ VERSION} ${ branchNameTag} ${ timeStamp}  
170+             docker tag ${ operatorRepo} ${ VERSION} ${ operatorRegistry} ${ operatorRepo}  
171+ 
172+             # Push images to internal registry 
173+             docker push ${ operatorRegistry} ${ operatorRepo} ${ VERSION}  
174+             docker push ${ operatorRegistry} ${ operatorRepo} ${ VERSION} ${ branchNameTag}  
175+             docker push ${ operatorRegistry} ${ operatorRepo} ${ VERSION} ${ branchNameTag} ${ timeStamp}  
176+             docker push ${ operatorRegistry} ${ operatorRepo}  
177+         """  
178+     }
179+ }
180+ 
149181pipeline {
150182    agent {
151183        label {
@@ -157,16 +189,17 @@ pipeline {
157189        buildDiscarder logRotator(artifactDaysToKeepStr : ' 20' artifactNumToKeepStr : ' ' daysToKeepStr : ' 30' numToKeepStr : ' ' 
158190        skipStagesAfterUnstable()
159191    }
160-     //  triggers { 
161-     //      //TODO: add scheduled runs 
162-     //  } 
163-     //  environment { 
164-     //      //TODO 
165-     //   }
192+     
193+     triggers { 
194+          //  Trigger nightly builds on the develop branch 
195+         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 
196+                                                              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 '''    :   ' ' ) 
197+     }
166198
167199    parameters {
168200        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 )
169-         string(name : ' IMG' defaultValue : ' testrepo/marklogic-operator-image-dev:internal' description : ' Docker image for Running Operator Container' trim : true )
201+         string(name : ' VERSION' defaultValue : ' 1.1.0' description : ' Version to tag the image with.' trim : true )
202+         booleanParam(name : ' PUBLISH_IMAGE' defaultValue : false , description : ' Publish image to internal registry' 
170203        string(name : ' emailList' defaultValue : emailList, description : ' List of email for build notification' trim : true )
171204    }
172205
@@ -206,6 +239,19 @@ pipeline {
206239                runMinikubeCleanup()
207240            }
208241        }
242+ 
243+         //  Publish image to internal registries (conditional)
244+         stage(' Publish Image' 
245+             when {
246+                     anyOf {
247+                         branch ' develop' 
248+                         expression { return  params. PUBLISH_IMAGE  }
249+                     }
250+             }
251+             steps {
252+                 publishToInternalRegistry()
253+             }
254+         }
209255
210256    }
211257
0 commit comments