-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uses newest scoring timestamp as etag header (#472)
Co-authored-by: Hervé Le Meur <[email protected]>
- Loading branch information
1 parent
ce0faa7
commit 4b9657a
Showing
5 changed files
with
186 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -25,3 +25,7 @@ node_modules/ | |
### IDE | ||
*.iml | ||
*.idea | ||
|
||
### fetch-report.sh | ||
etags.txt | ||
scores.json |
This file contains 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,60 @@ | ||
def cronExpr = env.BRANCH_IS_PRIMARY ? 'H * * * *' : '' | ||
|
||
def reportsFolder = 'plugin-health-scoring' | ||
def etagsFile = 'etags.txt' | ||
def reportFile = 'scores.json' | ||
def reportLines = 0 | ||
|
||
pipeline { | ||
agent any | ||
|
||
options { | ||
buildDiscarder(logRotator(numToKeepStr: '10')) | ||
timeout(time: 5, unit: 'MINUTES') | ||
disableConcurrentBuilds() | ||
} | ||
|
||
triggers { | ||
cron( cronExpr ) | ||
} | ||
|
||
stages { | ||
stage('Fetch API') { | ||
environment { | ||
REPORTS_FOLDER = reportsFolder | ||
ETAGS_FILE = etagsFile | ||
REPORT_FILE = reportFile | ||
URL = 'https://plugin-health.jenkins.io/api/scores' | ||
} | ||
|
||
steps { | ||
reportLines = sh(returnStdout:true, script: ''' | ||
curl -LSsO https://reports.jenkins.io/${REPORTS_FOLDER}/${ETAGS_FILE} || echo "No previous etags file." | ||
bash fetch-report.sh | ||
mkdir -p "${reportsFolder}" | ||
cp ${REPORT_FILE} ${ETAGS_FILE} ${REPORTS_FOLDER} | ||
|
||
wc -l ${REPORT_FILE} | ||
''').trim() | ||
} | ||
|
||
post { | ||
success { | ||
archiveArtifacts artifacts: "${reportFile}, ${etagsFile}" | ||
} | ||
} | ||
} | ||
|
||
stage('Publish') { | ||
when { | ||
expression { | ||
infra.isInfra() && reportLines > 0 | ||
} | ||
} | ||
|
||
steps { | ||
publishReports([ "${reportsFolder}/${reportFile}", "${reportsFolder}/${etagsFile}" ]) | ||
} | ||
} | ||
} | ||
} |
This file contains 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,35 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
# | ||
# MIT License | ||
# | ||
# Copyright (c) 2024 Jenkins Infra | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# | ||
|
||
### | ||
# using --compact-output to reduce output file by half. | ||
# adding report generation date in 'lastUpdate' key of the report. | ||
### | ||
curl --etag-compare "${ETAGS_FILE}" \ | ||
--etag-save "${ETAGS_FILE}" \ | ||
-LSs "${URL}" \ | ||
| jq --compact-output '. + { lastUpdate: (now | todate) }' > "${REPORT_FILE}" |
This file contains 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
This file contains 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