-
Notifications
You must be signed in to change notification settings - Fork 29
Add Jenkins pipeline for SUSE image health check #1982
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
Open
jordimassaguerpla
wants to merge
8
commits into
master
Choose a base branch
from
add_suse_health_check
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
71bc368
Add Jenkins pipeline for SUSE image health check
jordimassaguerpla c2b2bd2
Add daily cron trigger to Jenkins pipeline
jordimassaguerpla 6cc0ef3
Update jenkins_pipelines/mlm_ai/Jenkinsfile_mlm_51_ai_registry_health…
jordimassaguerpla df83eb7
Update jenkins_pipelines/mlm_ai/Jenkinsfile_mlm_51_ai_registry_health…
jordimassaguerpla f1bcb8d
Update jenkins_pipelines/mlm_ai/Jenkinsfile_mlm_51_ai_registry_health…
jordimassaguerpla 7a2e845
Update jenkins_pipelines/mlm_ai/Jenkinsfile_mlm_51_ai_registry_health…
jordimassaguerpla 968b2d2
Update jenkins_pipelines/mlm_ai/Jenkinsfile_mlm_51_ai_registry_health…
jordimassaguerpla 9f6d880
Update jenkins_pipelines/mlm_ai/Jenkinsfile_mlm_51_ai_registry_health…
jordimassaguerpla 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
68 changes: 68 additions & 0 deletions
68
jenkins_pipelines/mlm_ai/Jenkinsfile_mlm_51_ai_registry_health_status
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 |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| pipeline { | ||
| agent { | ||
| label 'sumaform-cucumber' | ||
| } | ||
|
|
||
| options { | ||
| timestamps() | ||
| timeout(time: 10, unit: 'MINUTES') | ||
|
jordimassaguerpla marked this conversation as resolved.
|
||
| } | ||
| triggers { | ||
| // 'H H * * *' tells Jenkins to pick a random time once a day | ||
| // This is better for server performance than '0 0 * * *' | ||
| cron('H H * * *') | ||
| } | ||
| environment { | ||
| // The URL of the image repository page | ||
| TARGET_URL = 'https://registry.suse.com/repositories/suse-agentic-mcp-multi-linux-manager' | ||
| } | ||
|
|
||
| stages { | ||
| stage('Check SUSE Image Health') { | ||
| steps { | ||
| script { | ||
| echo "Checking Health Index for: ${env.TARGET_URL}" | ||
|
|
||
| /** | ||
| * The Shell Script Logic: | ||
| * 1. set -o pipefail: Fail the pipeline if any command in it fails. | ||
| * 2. curl -sL: Fetch page silently, follow redirects. | ||
| * 3. -H "User-Agent...": Mimic a browser to avoid being blocked. | ||
| * 4. grep -oE 'grade-[A-Z]' | sed 's/grade-//': Look for 'grade-X' and return only 'X' using portable tools. | ||
| * 5. head -1: Ensure we only get the first match (usually the main badge). | ||
| */ | ||
| def healthGrade = sh( | ||
| script: """#!/usr/bin/env bash | ||
| set -o pipefail | ||
| curl -sL -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)" "${env.TARGET_URL}" | \ | ||
| grep -oE 'grade-[A-Z]' | \ | ||
| sed 's/grade-//' | \ | ||
| head -1 | ||
| """, | ||
| returnStdout: true | ||
| ).trim() | ||
|
|
||
| if (!healthGrade) { | ||
| error "FAIL: Could not find the Health Index on the page. The site layout might have changed." | ||
| } | ||
|
jordimassaguerpla marked this conversation as resolved.
|
||
|
|
||
| echo "Detected Health Grade: ${healthGrade}" | ||
|
|
||
| if (healthGrade == 'A') { | ||
|
jordimassaguerpla marked this conversation as resolved.
|
||
| echo "SUCCESS: Image is healthy (Grade A)." | ||
| } else { | ||
| // This will stop the pipeline and mark it as 'Failure' | ||
| error "FAIL: Image health check did not meet the required threshold. Detected grade: '${healthGrade}'. URL: ${env.TARGET_URL}" | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| post { | ||
| always { | ||
| echo "Finished Health Check." | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
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.