From 0fbb0c118c7ef26c23a4e52a5642b37002de08e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= <91831478+lemeurherve@users.noreply.github.com> Date: Mon, 1 Jul 2024 14:43:34 +0200 Subject: [PATCH] feat: retrieve data from infra-statistics (#67) --- .gitignore | 3 +++ Jenkinsfile | 10 ++++++++++ Jenkinsfile_previews | 10 ++++++++++ README.md | 3 ++- retrieve-infra-statistics-data.sh | 16 ++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 retrieve-infra-statistics-data.sh diff --git a/.gitignore b/.gitignore index a547bf3..e5925bc 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ dist-ssr *.njsproj *.sln *.sw? + +# infra-statistics +src/data/infra-statistics diff --git a/Jenkinsfile b/Jenkinsfile index 847f2e7..5ee90b1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,6 +10,10 @@ pipeline { label 'linux-arm64-docker || arm64linux' } + environment { + INFRASTATISTICS_LOCATION = 'src/data/infra-statistics' + } + stages { stage('Check for typos') { steps { @@ -39,6 +43,12 @@ pipeline { } } + stage('Retrieve data from infra-statistics') { + steps { + sh './retrieve-infra-statistics-data.sh' + } + } + stage('Build') { steps { sh ''' diff --git a/Jenkinsfile_previews b/Jenkinsfile_previews index 9ee1783..20122d5 100644 --- a/Jenkinsfile_previews +++ b/Jenkinsfile_previews @@ -10,6 +10,10 @@ pipeline { label 'linux-arm64-docker || arm64linux' } + environment { + INFRASTATISTICS_LOCATION = 'src/data/infra-statistics' + } + stages { stage('Install dependencies') { when { @@ -27,6 +31,12 @@ pipeline { } } + stage('Retrieve data from infra-statistics') { + steps { + sh './retrieve-infra-statistics-data.sh' + } + } + stage('Build') { when { allOf{ diff --git a/README.md b/README.md index 8acbf81..7f0a2d6 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,12 @@ If you are developing a production application, we recommend updating the config To build the website locally, follow these steps: -1. **Clone the repository:** +1. **Clone the repository and retrieve data from infra-statistics:** ```sh git clone https://github.com/jenkins-infra/stats.jenkins.io.git cd stats.jenkins.io + ./retrieve-infra-statistics-data.sh ``` 2. **Install dependencies:** diff --git a/retrieve-infra-statistics-data.sh b/retrieve-infra-statistics-data.sh new file mode 100755 index 0000000..be8b81e --- /dev/null +++ b/retrieve-infra-statistics-data.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -o nounset +set -o errexit +set -x + +command -v "curl" >/dev/null || { echo "[ERROR] no 'curl' command found."; exit 1; } +command -v "unzip" >/dev/null || { echo "[ERROR] no 'unzip' command found."; exit 1; } + +INFRASTATISTICS_LOCATION="${INFRASTATISTICS_LOCATION:-src/data/infra-statistics}" + +curl --silent --fail --output infra-statistics-gh-pages.zip --location "https://github.com/jenkins-infra/infra-statistics/archive/refs/heads/gh-pages.zip" +# Decompress silently and overwrite existing files +unzip -q -o infra-statistics-gh-pages.zip +mv infra-statistics-gh-pages "${INFRASTATISTICS_LOCATION}" +rm infra-statistics-gh-pages.zip