diff --git a/jenkins/artifacts/jenkinsfile b/jenkins/artifacts/jenkinsfile index 2f226c9..b00b8d0 100644 --- a/jenkins/artifacts/jenkinsfile +++ b/jenkins/artifacts/jenkinsfile @@ -5,7 +5,9 @@ pipeline { string(name: 'VERSION', defaultValue: '', description: '[Optional] Version. If not filled default is YY.mm.ddHH.') string(name: 'RELEASE', defaultValue: 'nightly', description: '[Optional] Example: nightly (default)') string(name: 'BRANCH', defaultValue: 'main', description: '[Optional] Branch name to clone. Default (main) ') + string(name: 'DOCKER_PUBLISH', defaultValue: 'false', description: 'true to publish to ghcr.io') string(name: 'RUN_TEST', defaultValue: 'true', description: 'false to skip test') + string(name: 'OVERWRITE_DOCKER_LATEST_TAG', defaultValue: 'false', description: 'true to overwrite latest tag at ghcr.io. Works only if DOCKER_PUBLISH is true') } environment { @@ -17,6 +19,12 @@ pipeline { echo \"${params.RELEASE}\" """).trim() BRANCH = getBranchName(env.CHANGE_BRANCH, params.BRANCH) + DOCKER_PUBLISH = sh (returnStdout: true, script: """ + echo \"${params.DOCKER_PUBLISH}\" + """).trim() + OVERWRITE_DOCKER_LATEST_TAG = sh (returnStdout: true, script: """ + echo \"${params.OVERWRITE_DOCKER_LATEST_TAG}\" + """).trim() targetParentLocation = "/opt/home/nightly/" ontapMcpPath = "ontap-mcp" ghcrOntapMcpImage = "ghcr.io/netapp/ontap-mcp" @@ -122,6 +130,32 @@ pipeline { } } + stage('Publish ONTAP MCP Docker Image') { + when { + expression { + return env.DOCKER_PUBLISH == 'true' + } + } + steps { + withCredentials([string(credentialsId: 'GIT_ONTAP_MCP_TOKEN', variable: 'GIT_ONTAP_MCP_TOKEN')]) { + script { + currentStage = 'Publish ONTAP MCP Docker Image' + } + sh ''' + echo $GIT_ONTAP_MCP_TOKEN | docker login ghcr.io -u $USERNAME --password-stdin + docker push ${ghcrOntapMcpImage}:$VERSION-$RELEASE + ''' + script { + if (env.OVERWRITE_DOCKER_LATEST_TAG == 'true') { + sh ''' + docker push ${ghcrOntapMcpImage}:latest + ''' + } + } + } + } + } + stage('Publish Nightly to GitHub') { when { expression { @@ -144,8 +178,6 @@ pipeline { docker tag ${ghcrOntapMcpImage}:latest ${ghcrOntapMcpImage}:nightly echo $GIT_ONTAP_MCP_TOKEN | docker login ghcr.io -u $USERNAME --password-stdin docker push ${ghcrOntapMcpImage}:nightly - # TODO: Remove pushing latest once GA release is published - docker push ${ghcrOntapMcpImage}:latest # Add a dummy user/email for mike deploy to work git config user.name ontap-mcp git config user.email ontap-mcp