Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions jenkins/artifacts/jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
Comment thread
rahulguptajss marked this conversation as resolved.
targetParentLocation = "/opt/home/nightly/"
ontapMcpPath = "ontap-mcp"
ghcrOntapMcpImage = "ghcr.io/netapp/ontap-mcp"
Expand Down Expand Up @@ -122,6 +130,32 @@ pipeline {
}
}

stage('Publish ONTAP MCP Docker Image') {
when {
expression {
return env.DOCKER_PUBLISH == 'true'
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The publish stage can run purely based on the DOCKER_PUBLISH parameter, which means a PR build or any non-main build could publish images to GHCR if someone triggers the job with this param set to true. Please restrict publishing to trusted contexts (e.g., only when BRANCH == 'main' and CHANGE_ID is not set / not a PR build, or require a manual approval/input step) to avoid publishing unreviewed code and exposing credentials in PR jobs.

Suggested change
return env.DOCKER_PUBLISH == 'true'
return params.DOCKER_PUBLISH == 'true' &&
params.BRANCH == 'main' &&
!env.CHANGE_ID

Copilot uses AI. Check for mistakes.
}
}
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
'''
Comment thread
rahulguptajss marked this conversation as resolved.
script {
if (env.OVERWRITE_DOCKER_LATEST_TAG == 'true') {
sh '''
docker push ${ghcrOntapMcpImage}:latest
'''
}
}
}
}
}

stage('Publish Nightly to GitHub') {
when {
expression {
Expand All @@ -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
Expand Down
Loading