-
Notifications
You must be signed in to change notification settings - Fork 48
Create check_mysql_repo.groovy #3556
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
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| def awsCredentials = [[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: '4422eb0c-26be-4454-8823-fc76b9b3b120']] | ||
|
|
||
| void sendMessage(String REPO_NAME, String REPO_URL) { | ||
| TAGS = sh ( | ||
| script: "cat ${REPO_NAME}.newtags", | ||
| returnStdout: true | ||
| ) | ||
|
|
||
| if (TAGS) { | ||
| slackSend channel: "${ReposSlackMap["$REPO_NAME"]}", color: '#00FF00', message: "[${JOB_NAME}]: New tag(s) have been created for ${REPO_NAME}, please check the following link(s):\n${TAGS}" | ||
| } else { | ||
| sh (script: "rm -rf ${REPO_NAME}.newtags", returnStdout: false) | ||
| } | ||
| } | ||
|
|
||
| void checkRepo(String REPO_NAME, String REPO_URL) { | ||
| popArtifactFile("${REPO_NAME}.last") | ||
| sh """ | ||
| if [ -n ${REPO_NAME}.last ]; then | ||
EvgeniyPatlan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| git ls-remote --tags --refs ${REPO_URL} | awk -F'/' '{print \$3}' | sort | uniq > ${REPO_NAME}.current | ||
| cat ${REPO_NAME}.last ${REPO_NAME}.current | sort | uniq -u | awk '{print "$REPO_URL/tree/"\$1}' > ${REPO_NAME}.newtags | ||
| mv -fv ${REPO_NAME}.current ${REPO_NAME}.last | ||
| else | ||
| git ls-remote --tags --refs ${REPO_URL} | awk -F'/' '{print \$3}' | sort | uniq > ${REPO_NAME}.last | ||
| fi | ||
|
|
||
| """ | ||
| pushArtifactFile("${REPO_NAME}.last") | ||
| } | ||
|
|
||
| void pushArtifactFile(String FILE_NAME) { | ||
| sh """ | ||
| S3_PATH=s3://rel-repo-cache | ||
| aws s3 ls \$S3_PATH/${FILE_NAME} || : | ||
| aws s3 cp --quiet ${FILE_NAME} \$S3_PATH/${FILE_NAME} || : | ||
| """ | ||
| } | ||
|
|
||
| void popArtifactFile(String FILE_NAME) { | ||
| sh """ | ||
| S3_PATH=s3://rel-repo-cache | ||
| aws s3 cp --quiet \$S3_PATH/${FILE_NAME} ${FILE_NAME} || : | ||
| """ | ||
| } | ||
|
|
||
| def GitHubURL='https://github.com' | ||
|
|
||
| // Filtered to only MySQL-related repositories | ||
| ReposPathMap = [ | ||
| 'MySQL': "${GitHubURL}/mysql/mysql-server", | ||
| 'MySQLShell': "${GitHubURL}/mysql/mysql-shell", | ||
| 'ProxySQL': "${GitHubURL}/sysown/proxysql", | ||
| 'MyRocks': "${GitHubURL}/facebook/mysql-5.6", | ||
| 'Galera': "${GitHubURL}/codership/galera", | ||
| 'MySQL-Wsrep': "${GitHubURL}/codership/mysql-wsrep", | ||
| 'Wsrep-API': "${GitHubURL}/codership/wsrep-API", | ||
| 'SysBench': "${GitHubURL}/akopytov/sysbench", | ||
| 'HAProxy': "${GitHubURL}/haproxy/haproxy" | ||
| ] | ||
|
|
||
| // Corresponding Slack channels for MySQL repositories | ||
| ReposSlackMap = [ | ||
| 'MySQL': "#mysql", | ||
| 'MySQLShell': "#mysql", | ||
| 'ProxySQL': "#mysql", | ||
| 'MyRocks': "#mysql", | ||
| 'Galera': "#mysql", | ||
| 'MySQL-Wsrep': "#mysql", | ||
| 'Wsrep-API': "#mysql", | ||
| 'SysBench': "#mysql", | ||
| 'HAProxy': '#mysql' | ||
| ] | ||
|
|
||
| pipeline { | ||
| agent { | ||
| label 'micro-amazon' | ||
| } | ||
| triggers { | ||
| // Hourly on months 1,4,7,10 from 2nd week to 4th week (days 8-28) | ||
| cron('H * 8-28 1,4,7,10 *') | ||
| } | ||
| options { | ||
| skipStagesAfterUnstable() | ||
| disableConcurrentBuilds() | ||
| buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10')) | ||
| withCredentials(awsCredentials) | ||
| } | ||
| stages { | ||
| stage('Check MySQL Repos') { | ||
| steps { | ||
| script { | ||
| ReposPathMap.each { repo_info -> | ||
| checkRepo("${repo_info.key}", "${repo_info.value}") | ||
| } | ||
| } | ||
| stash allowEmpty: true, includes: "*.newtags", name: "NewTagsFiles" | ||
| } | ||
| } | ||
| stage('Process New Tags') { | ||
| when { | ||
| expression { | ||
| // Check if any repo has new tags using same logic as sendMessage function | ||
| def hasNewTags = false | ||
| ReposPathMap.each { repo_info -> | ||
| try { | ||
| def tags = sh( | ||
| script: "cat ${repo_info.key}.newtags 2>/dev/null || echo ''", | ||
| returnStdout: true | ||
| ).trim() | ||
| if (tags) { | ||
| hasNewTags = true | ||
| } | ||
| } catch (Exception e) { | ||
| // File doesn't exist, continue | ||
| } | ||
| } | ||
| return hasNewTags | ||
| } | ||
| } | ||
| steps { | ||
| script { | ||
| echo "New tags detected, downloading and executing processing script..." | ||
|
|
||
| // Download the script | ||
| sh """ | ||
| curl -fsSL -o gen_csv_diff.sh https://raw.githubusercontent.com/VarunNagaraju/sh/refs/heads/master/gen_csv_diff.sh | ||
| chmod +x gen_csv_diff.sh | ||
| """ | ||
|
|
||
| // Execute the script | ||
| sh "./gen_csv_diff.sh" | ||
| } | ||
| } | ||
| } | ||
| stage('Sending notifications') { | ||
| steps { | ||
| unstash "NewTagsFiles" | ||
| script { | ||
| ReposPathMap.each { repo_info -> | ||
| sendMessage("${repo_info.key}", "${repo_info.value}") | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| post { | ||
| always { | ||
| archiveArtifacts artifacts: '*.newtags', allowEmptyArchive: true | ||
| deleteDir() | ||
| } | ||
| } | ||
| } | ||
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.