Skip to content

Commit

Permalink
Still generate fixed tier update sites in addition to dynamic ones
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck committed Jun 18, 2020
1 parent 583bee5 commit 912eee4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 27 deletions.
16 changes: 8 additions & 8 deletions site/generate-htaccess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -84,17 +84,17 @@ cat <<EOF
# First LTS update site (stable-$oldestStable) gets all older LTS releases
RewriteCond %{QUERY_STRING} ^.*version=\d\.(\d+)\.\d+$ [NC]
RewriteRule ^(update\-center.*\.(json|html)+) /stable-${oldestStable}%{REQUEST_URI}? [NC,L,R=301]
RewriteRule ^(update\-center.*\.(json|html)+) /dynamic-stable-${oldestStable}%{REQUEST_URI}? [NC,L,R=301]
RewriteCond %{QUERY_STRING} ^.*version=\d\.(\d+)+$ [NC]
RewriteRule ^(update\-center.*\.(json|html)+) /${oldestWeekly}%{REQUEST_URI}? [NC,L,R=301]
RewriteRule ^(update\-center.*\.(json|html)+) /dynamic-${oldestWeekly}%{REQUEST_URI}? [NC,L,R=301]
EOF


echo "# Add a RewriteRule for /stable which will always rewrite to the last LTS site we have"
cat <<EOF
RewriteRule ^stable/(.+) "/stable-${newestStable}/\$1" [NC,L,R=301]
RewriteRule ^stable/(.+) "/dynamic-stable-${newestStable}/\$1" [NC,L,R=301]
EOF

Expand Down
27 changes: 25 additions & 2 deletions site/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ java -Dfile.encoding=UTF-8 -jar "$MAIN_DIR"/tmp/generator/update-center2-*.jar -
readarray -t WEEKLY_RELEASES < <( jq --raw-output '.weeklyCores[]' tmp/tiers.json ) || { echo "Failed to determine weekly tier list" >&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"
Expand Down Expand Up @@ -90,12 +93,22 @@ 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.
Expand Down Expand Up @@ -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"
Expand Down
34 changes: 17 additions & 17 deletions site/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 912eee4

Please sign in to comment.