From 9c1be5ac806cca23b669b43148b2485698ec1e91 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Thu, 18 Jun 2020 13:50:00 +0200 Subject: [PATCH] Still generate fixed tier update sites in addition to dynamic ones --- site/generate-htaccess.sh | 16 ++++++++-------- site/generate.sh | 31 +++++++++++++++++++++++++++---- site/test/test.sh | 34 +++++++++++++++++----------------- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/site/generate-htaccess.sh b/site/generate-htaccess.sh index 01ba99805..4acc63abb 100755 --- a/site/generate-htaccess.sh +++ b/site/generate-htaccess.sh @@ -46,16 +46,16 @@ for (( i = n-1 ; i >= 0 ; i-- )) ; do # If major > ${major} or major = ${major} and minor >= ${minor} or major = ${major} and minor = ${minor} and patch >= ${patch}, use this LTS update site RewriteCond %{QUERY_STRING} ^.*version=(\d)\.(\d+)\.(\d+)$ [NC] RewriteCond %1 >${major} -RewriteRule ^(update\-center.*\.(json|html)+) /stable-${major}\.${minor}\.${patch}%{REQUEST_URI}? [NC,L,R=301] +RewriteRule ^(update\-center.*\.(json|html)+) /dynamic-stable-${major}\.${minor}\.${patch}%{REQUEST_URI}? [NC,L,R=301] RewriteCond %{QUERY_STRING} ^.*version=(\d)\.(\d+)\.(\d+)$ [NC] RewriteCond %1 =${major} RewriteCond %2 >=${minor} -RewriteRule ^(update\-center.*\.(json|html)+) /stable-${major}\.${minor}\.${patch}%{REQUEST_URI}? [NC,L,R=301] +RewriteRule ^(update\-center.*\.(json|html)+) /dynamic-stable-${major}\.${minor}\.${patch}%{REQUEST_URI}? [NC,L,R=301] RewriteCond %{QUERY_STRING} ^.*version=(\d)\.(\d+)\.(\d+)$ [NC] RewriteCond %1 =${major} RewriteCond %2 =${minor} RewriteCond %3 >=${minor} -RewriteRule ^(update\-center.*\.(json|html)+) /stable-${major}\.${minor}\.${patch}%{REQUEST_URI}? [NC,L,R=301] +RewriteRule ^(update\-center.*\.(json|html)+) /dynamic-stable-${major}\.${minor}\.${patch}%{REQUEST_URI}? [NC,L,R=301] EOF oldestStable="$version" else @@ -68,11 +68,11 @@ EOF # If major > ${major} or major = ${major} and minor >= ${minor}, use this weekly update site RewriteCond %{QUERY_STRING} ^.*version=(\d)\.(\d+)$ [NC] RewriteCond %1 >${major} -RewriteRule ^(update\-center.*\.(json|html)+) /${major}\.${minor}%{REQUEST_URI}? [NC,L,R=301] +RewriteRule ^(update\-center.*\.(json|html)+) /dynamic-${major}\.${minor}%{REQUEST_URI}? [NC,L,R=301] RewriteCond %{QUERY_STRING} ^.*version=(\d)\.(\d+)$ [NC] RewriteCond %1 =${major} RewriteCond %2 >${minor} -RewriteRule ^(update\-center.*\.(json|html)+) /${major}\.${minor}%{REQUEST_URI}? [NC,L,R=301] +RewriteRule ^(update\-center.*\.(json|html)+) /dynamic-${major}\.${minor}%{REQUEST_URI}? [NC,L,R=301] EOF fi @@ -84,17 +84,17 @@ cat <&2 ; exit 1 ; } readarray -t STABLE_RELEASES < <( jq --raw-output '.stableCores[]' tmp/tiers.json ) || { echo "Failed to determine stable tier list" >&2 ; exit 1 ; } +# Workaround for https://github.com/jenkinsci/docker/issues/954 -- still generate fixed tier update sites +readarray -t RELEASES < <( curl --silent --fail 'https://repo.jenkins-ci.org/api/search/versions?g=org.jenkins-ci.main&a=jenkins-core&repos=releases&v=?.*.1' | jq --raw-output '.results[].version' | head -n 5 | $SORT --version-sort ) || { echo "Failed to retrieve list of recent LTS releases" >&2 ; exit 1 ; } + # prepare the www workspace for execution rm -rf "$WWW_ROOT_DIR" mkdir -p "$WWW_ROOT_DIR" @@ -90,25 +93,35 @@ function sanity-check { # This supports updating Jenkins (core) once a year while getting offered compatible plugin updates. for version in "${WEEKLY_RELEASES[@]}" ; do # For mainline, advertising the latest core - generate --limit-plugin-core-dependency "$version.999" --write-latest-core --latest-links-directory "$WWW_ROOT_DIR/$version/latest" --www-dir "$WWW_ROOT_DIR/$version" + generate --limit-plugin-core-dependency "$version" --write-latest-core --latest-links-directory "$WWW_ROOT_DIR/dynamic-$version/latest" --www-dir "$WWW_ROOT_DIR/dynamic-$version" done for version in "${STABLE_RELEASES[@]}" ; do # For LTS, advertising the latest LTS core - generate --limit-plugin-core-dependency "$version.999" --write-latest-core --latest-links-directory "$WWW_ROOT_DIR/stable-$version/latest" --www-dir "$WWW_ROOT_DIR/stable-$version" --only-stable-core + generate --limit-plugin-core-dependency "$version" --write-latest-core --latest-links-directory "$WWW_ROOT_DIR/dynamic-stable-$version/latest" --www-dir "$WWW_ROOT_DIR/dynamic-stable-$version" --only-stable-core +done + +# Workaround for https://github.com/jenkinsci/docker/issues/954 -- still generate fixed tier update sites +for ltsv in "${RELEASES[@]}" ; do + v="${ltsv/%.1/}" + # For mainline up to $v, advertising the latest core + generate --limit-plugin-core-dependency "$v.999" --write-latest-core --latest-links-directory "$WWW_ROOT_DIR/$v/latest" --www-dir "$WWW_ROOT_DIR/$v" + + # For LTS, advertising the latest LTS core + generate --limit-plugin-core-dependency "$v.999" --write-latest-core --latest-links-directory "$WWW_ROOT_DIR/stable-$v/latest" --www-dir "$WWW_ROOT_DIR/stable-$v" --only-stable-core done # Experimental update center without version caps, including experimental releases. # This is not a part of the version-based redirection rules, admins need to manually configure it. # Generate this first, including --downloads-directory, as this includes all releases, experimental and otherwise. -generate --www-dir "$WWW_ROOT_DIR/experimental" --with-experimental --downloads-directory "$DOWNLOAD_ROOT_DIR" --latest-links-directory "$WWW_ROOT_DIR/experimental/latest" +generate --www-dir "$WWW_ROOT_DIR/experimental" --with-experimental --latest-links-directory "$WWW_ROOT_DIR/experimental/latest" # Current update site without version caps, excluding experimental releases. # This generates -download after the experimental update site above to change the 'latest' symlinks to the latest released version. # This also generates --download-links-directory to only visibly show real releases on index.html pages. generate --generate-release-history --generate-plugin-versions --generate-plugin-documentation-urls \ --write-latest-core --write-plugin-count \ - --www-dir "$WWW_ROOT_DIR/current" --download-links-directory "$WWW_ROOT_DIR/download" --downloads-directory "$DOWNLOAD_ROOT_DIR" --latest-links-directory "$WWW_ROOT_DIR/current/latest" + --www-dir "$WWW_ROOT_DIR/current" --download-links-directory "$WWW_ROOT_DIR/download" --latest-links-directory "$WWW_ROOT_DIR/current/latest" # Actually run the update center build. # The fastjson library cannot handle a file.encoding of US-ASCII even when manually specifying the encoding at every opportunity, so set a sane default here. @@ -127,6 +140,16 @@ for ltsv in "${RELEASES[@]}" ; do lastLTS=$v done +for version in "${WEEKLY_RELEASES[@]}" ; do + sanity-check "$WWW_ROOT_DIR/dynamic-$version" + ln -sf ../updates "$WWW_ROOT_DIR/dynamic-$version/updates" +done + +for version in "${STABLE_RELEASES[@]}" ; do + sanity-check "$WWW_ROOT_DIR/dynamic-stable-$version" + ln -sf ../updates "$WWW_ROOT_DIR/dynamic-stable-$version/updates" +done + sanity-check "$WWW_ROOT_DIR/experimental" sanity-check "$WWW_ROOT_DIR/current" ln -sf ../updates "$WWW_ROOT_DIR/experimental/updates" diff --git a/site/test/test.sh b/site/test/test.sh index ec6d53e2a..e1dabd481 100755 --- a/site/test/test.sh +++ b/site/test/test.sh @@ -50,34 +50,34 @@ test_redirect "$TEST_BASE_URL/plugin-documentation-urls.json" "$TEST_BASE_URL/cu test_redirect "$TEST_BASE_URL/latestCore.txt" "$TEST_BASE_URL/current/latestCore.txt" -test_redirect "$TEST_BASE_URL/stable/update-center.json" "$TEST_BASE_URL/stable-2.222.1/update-center.json" +test_redirect "$TEST_BASE_URL/stable/update-center.json" "$TEST_BASE_URL/dynamic-stable-2.222.1/update-center.json" # Accessed by https://github.com/jenkins-infra/jenkins.io/blob/3892ea2ad4b4a67e1f8aebbfab261ae88628c176/scripts/fetch-external-resources#L24 -test_redirect "$TEST_BASE_URL/stable/latestCore.txt" "$TEST_BASE_URL/stable-2.222.1/latestCore.txt" +test_redirect "$TEST_BASE_URL/stable/latestCore.txt" "$TEST_BASE_URL/dynamic-stable-2.222.1/latestCore.txt" -test_redirect "$TEST_BASE_URL/update-center.json?version=2.236" "$TEST_BASE_URL/2.223/update-center.json" -test_redirect "$TEST_BASE_URL/update-center.json?version=2.230" "$TEST_BASE_URL/2.223/update-center.json" -test_redirect "$TEST_BASE_URL/update-center.json?version=2.222" "$TEST_BASE_URL/2.217/update-center.json" -test_redirect "$TEST_BASE_URL/update-center.json?version=2.222.1" "$TEST_BASE_URL/stable-2.222.1/update-center.json" -test_redirect "$TEST_BASE_URL/update-center.json?version=2.55" "$TEST_BASE_URL/2.172/update-center.json" # TODO Fix -test_redirect "$TEST_BASE_URL/update-center.json?version=2.6" "$TEST_BASE_URL/2.172/update-center.json" # TODO Fix +test_redirect "$TEST_BASE_URL/update-center.json?version=2.236" "$TEST_BASE_URL/dynamic-2.223/update-center.json" +test_redirect "$TEST_BASE_URL/update-center.json?version=2.230" "$TEST_BASE_URL/dynamic-2.223/update-center.json" +test_redirect "$TEST_BASE_URL/update-center.json?version=2.222" "$TEST_BASE_URL/dynamic-2.217/update-center.json" +test_redirect "$TEST_BASE_URL/update-center.json?version=2.222.1" "$TEST_BASE_URL/dynamic-stable-2.222.1/update-center.json" +test_redirect "$TEST_BASE_URL/update-center.json?version=2.55" "$TEST_BASE_URL/dynamic-2.172/update-center.json" # TODO Fix +test_redirect "$TEST_BASE_URL/update-center.json?version=2.6" "$TEST_BASE_URL/dynamic-2.172/update-center.json" # TODO Fix -test_redirect "$TEST_BASE_URL/update-center.actual.json?version=2.222" "$TEST_BASE_URL/2.217/update-center.actual.json" -test_redirect "$TEST_BASE_URL/update-center.actual.json?version=2.222.1" "$TEST_BASE_URL/stable-2.222.1/update-center.actual.json" +test_redirect "$TEST_BASE_URL/update-center.actual.json?version=2.222" "$TEST_BASE_URL/dynamic-2.217/update-center.actual.json" +test_redirect "$TEST_BASE_URL/update-center.actual.json?version=2.222.1" "$TEST_BASE_URL/dynamic-stable-2.222.1/update-center.actual.json" # No more redirects to tiers test_redirect "$TEST_BASE_URL/plugin-documentation-urls.json?version=2.222.1" "$TEST_BASE_URL/current/plugin-documentation-urls.json" test_redirect "$TEST_BASE_URL/latestCore.txt?version=2.222.1" "$TEST_BASE_URL/current/latestCore.txt" # Jenkins 1.x gets the oldest update sites -test_redirect "$TEST_BASE_URL/update-center.json?version=1.650" "$TEST_BASE_URL/2.172/update-center.json" # TODO Fix -test_redirect "$TEST_BASE_URL/update-center.json?version=1.580" "$TEST_BASE_URL/2.172/update-center.json" # TODO Fix -test_redirect "$TEST_BASE_URL/update-center.json?version=1.580.1" "$TEST_BASE_URL/stable-2.164.2/update-center.json" -test_redirect "$TEST_BASE_URL/update-center.json?version=2.46.1" "$TEST_BASE_URL/stable-2.164.2/update-center.json" +test_redirect "$TEST_BASE_URL/update-center.json?version=1.650" "$TEST_BASE_URL/dynamic-2.172/update-center.json" # TODO Fix +test_redirect "$TEST_BASE_URL/update-center.json?version=1.580" "$TEST_BASE_URL/dynamic-2.172/update-center.json" # TODO Fix +test_redirect "$TEST_BASE_URL/update-center.json?version=1.580.1" "$TEST_BASE_URL/dynamic-stable-2.164.2/update-center.json" +test_redirect "$TEST_BASE_URL/update-center.json?version=2.46.1" "$TEST_BASE_URL/dynamic-stable-2.164.2/update-center.json" # This would probably be ideal: Drop down if older than newest LTS baseline, this instance isn't getting updates weekly -test_redirect "$TEST_BASE_URL/update-center.json?version=2.200" "$TEST_BASE_URL/2.199/update-center.json" +test_redirect "$TEST_BASE_URL/update-center.json?version=2.200" "$TEST_BASE_URL/dynamic-2.199/update-center.json" # Future major releases go to the most recent update sites: -test_redirect "$TEST_BASE_URL/update-center.json?version=3.0" "$TEST_BASE_URL/2.223/update-center.json" -test_redirect "$TEST_BASE_URL/update-center.json?version=3.0.1" "$TEST_BASE_URL/stable-2.222.1/update-center.json" +test_redirect "$TEST_BASE_URL/update-center.json?version=3.0" "$TEST_BASE_URL/dynamic-2.223/update-center.json" +test_redirect "$TEST_BASE_URL/update-center.json?version=3.0.1" "$TEST_BASE_URL/dynamic-stable-2.222.1/update-center.json"