Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fabbe77

Browse files
MarkEWaitedduportal
andauthoredJan 21, 2023
Prevent absolute links from adoc to www.jenkins.io and jenkins.io (jenkins-infra#5899)
## Prevent absolute links to jenkins.io and www.jenkins.io in adoc files When the https://www.jenkins.io/ URL is embedded in the source code of the jenkins.io pages, it causes a user exploring a pull request through the preview sites to be moved from the preview site to the www.jenkins.io site. If they are not very carefully watching the URL address bar, they can waste time looking at the production site when they wanted to review the preview site. * jenkins-infra#5718 * jenkins-infra#5715 @ADITYADAS1999 I assumed that the issue was more difficult than you were ready to attack. If you'd like to review the technique I've used, I'd love to have comments or recommendations of ways it could be improved. Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
1 parent 19e18dd commit fabbe77

14 files changed

+64
-17
lines changed
 

‎Jenkinsfile

+12-5
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,16 @@ node('docker&&linux') {
4848
checkout scm
4949
}
5050

51-
stage('Check for typos') {
52-
sh 'make check'
53-
recordIssues(tools: [checkStyle(id: 'typos', name: 'Typos', pattern: 'checkstyle.xml')], qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]])
51+
stage('Checks') {
52+
/* The Jenkins which deploys doesn't use multibranch or GitHub Org Folders.
53+
* Checks are advisory only.
54+
* They are intentionally skipped when preparing a deployment.
55+
*/
56+
if (!infra.isTrusted() && env.BRANCH_NAME != null) {
57+
sh 'make check'
58+
recordIssues(tools: [checkStyle(id: 'typos', name: 'Typos', pattern: 'checkstyle.xml')],
59+
qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]])
60+
}
5461
}
5562

5663
stage('Build site') {
@@ -84,9 +91,9 @@ node('docker&&linux') {
8491
archiveArtifacts artifacts: 'build/**/*.zip', fingerprint: true
8592
}
8693

87-
/* The Jenkins which deploys doesn't use multibranch or GitHub Org Folders
94+
/* The Jenkins which deploys doesn't use multibranch or GitHub Org Folders.
8895
*/
89-
if (env.BRANCH_NAME == null) {
96+
if (infra.isTrusted() && env.BRANCH_NAME == null) {
9097
stage('Publish on Azure') {
9198
/* -> https://github.com/Azure/blobxfer
9299
Require credential 'BLOBXFER_STORAGEACCOUNTKEY' set to the storage account key */

‎Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ archive: generate
120120
# Check Typo
121121
#######################################################
122122
check:
123+
scripts/check-hard-coded-URL-references
123124
curl -qsL https://github.com/crate-ci/typos/releases/download/v1.13.4/typos-v1.13.4-x86_64-unknown-linux-musl.tar.gz | tar xvzf - ./typos
124125
curl -qsL https://github.com/halkeye/typos-json-to-checkstyle/releases/download/v0.1.1/typos-checkstyle-v0.1.1-x86_64 > typos-checkstyle && chmod 0755 typos-checkstyle
125126
./typos --format json | ./typos-checkstyle - > checkstyle.xml || true

‎content/events/hacktoberfest.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ who have committed to assist contributors and to provide quick turnaround in pul
7575
|=========================================================
7676
|Project/component | Keywords | Ideas and links
7777

78-
| link:https://jenkins.io[Jenkins Website]
78+
| link:/[Jenkins Website]
7979
| Documentation, +
8080
Asciidoc, +
8181
CSS, +

‎content/participate/report-issue.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ https://issues.jenkins.io/secure/Dashboard.jspa[the JIRA home page].
9090
* For *Project* select:
9191
** _Jenkins_ for general issues with Jenkins,
9292
** _Security Issues_ if you want to report a security issue privately
93-
* For _Infrastructure_, if you're reporting a bug with https://www.jenkins.io/projects/infrastructure/[a Jenkins service run by the Jenkins project], open an issue in the https://github.com/jenkins-infra/helpdesk/issues/new/choose[dedicated helpdesk on Github].
93+
* For _Infrastructure_, if you're reporting a bug with link:/projects/infrastructure/[a Jenkins service run by the Jenkins project], open an issue in the https://github.com/jenkins-infra/helpdesk/issues/new/choose[dedicated helpdesk on Github].
9494
* Enter a short but meaningful description of your problem as *Summary*.
9595
* For *Priority*, see
9696
https://issues.jenkins.io/secure/ShowConstantsHelp.jspa?decorator=popup#PriorityLevels[here]

‎content/participate/test.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ See the jira:WEBSITE-662[] EPIC for tasks related to this page, contributions ar
3434

3535
- Pull Requests - link:https://ci.jenkins.io/job/Core/job/jenkins/view/change-requests/[https://ci.jenkins.io/job/Core/job/jenkins/view/change-requests/]
3636

37-
- Weekly Release - link:/download/[https://jenkins.io/download/]
37+
- Weekly Release - link:/download/[weekly downloads]
3838

3939
- Quarterly Long Term Support Release Candidate - link:http://mirrors.jenkins.io/war-stable-rc/[http://mirrors.jenkins.io/war-stable-rc/]
4040

41-
- Quarterly Long Term Support Release - link:/download/[https://jenkins.io/download/]
41+
- Quarterly Long Term Support Release - link:/download/[LTS downloads]
4242

4343
==== Jenkins Plugins
4444
- Pull request builds from link:https://ci.jenkins.io/job/Plugins/[ci.jenkins.io]

‎content/project/conduct.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Technical criticism is always appreciated. Keep it positive and constructive. Do
9797

9898
Everything hosted under link:/[jenkins.io], link:https://jenkins-ci.org/[jenkins-ci.org] and their sub-domains such as:
9999

100-
* link:https://jenkins.io[jenkins.io]
100+
* link:/[jenkins.io]
101101
* link:https://issues.jenkins.io/[issues.jenkins.io]
102102
* link:https://stories.jenkins.io/[stories.jenkins.io]
103103

‎content/project/team-leads.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Coordinates the security-related activities in the Jenkins project. This is an *
4646
* Publish link:https://wiki.jenkins.io/display/JENKINS/Security+Advisorie[Security Advisories] (including CVE IDs and CVSS) and notify the link:https://groups.google.com/forum/#!forum/jenkinsci-advisories[mailing list]
4747
* Drive security policy definition/changes in the community
4848
* Represent the Jenkins project on security topics with third parties
49-
* Represent the https://www.jenkins.io/security/cna/[Jenkins CNA].
49+
* Represent the link:/security/cna/[Jenkins CNA].
5050

5151
[[infrastructure]]
5252
### Infrastructure Officer
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
layout: redirect
3-
redirect_url: https://jenkins.io/oracleAccountSignup # TODO get rid of double redirect
3+
redirect_url: /oracleAccountSignup # TODO get rid of double redirect
44
---
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
layout: redirect
3-
redirect_url: https://www.jenkins.io/doc/book/pipeline/cps-method-mismatches/
3+
redirect_url: /doc/book/pipeline/cps-method-mismatches/
44
---

‎content/security/plugins.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ This typically is the case when plugins have particularly severe security vulner
6666
* Literate (`literate`): link:/security/advisory/2020-03-09/#SECURITY-1750[SECURITY-1750]
6767
* Nerrvana (`nerrvana`): link:/security/advisory/2020-10-08/#SECURITY-2097[SECURITY-2097]
6868
* Persona (`persona`): link:/security/advisory/2020-10-08/#SECURITY-2046[SECURITY-2046]
69-
* Pipeline: Classpath Step (`pipeline-classpath`): https://www.jenkins.io/security/advisory/2017-03-20/#pipeline-classpath-step-plugin-allowed-script-security-sandbox-bypass[SECURITY-336]
69+
* Pipeline: Classpath Step (`pipeline-classpath`): link:/security/advisory/2017-03-20/#pipeline-classpath-step-plugin-allowed-script-security-sandbox-bypass[SECURITY-336]
7070
* Pipeline: Phoenix AutoTest (`phoenix-autotest`): link:/security/advisory/2022-03-29/[multiple vulnerabilities announced on 2022-03-29]
7171
* Puppet Enterprise Pipeline (`puppet-enterprise-pipeline`): link:/security/advisory/2019-10-16/#SECURITY-918[SECURITY-918]
7272
* Reactor (`reactor`): link:/security/advisory/2017-04-10/#reactor-plugin[SECURITY-487]

‎content/security/reporting.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Please report issues present in the following components:
2929
* Jenkins, including installers and Docker images published by the Jenkins project
3030
* Jenkins plugins published by the Jenkins project (listed on https://plugins.jenkins.io/[plugins.jenkins.io] and/or hosted in https://github.com/jenkinsci[the jenkinsci GitHub organization])
3131
* Additional components published by the Jenkins project for general use, such as Docker images
32-
* Jenkins infrastructure projects, such as https://www.jenkins.io/[jenkins.io] or more generally the repositories hosted in the https://github.com/jenkins-infra[jenkins-infra GitHub organization]
32+
* Jenkins infrastructure projects, such as link:/[jenkins.io] or more generally the repositories hosted in the https://github.com/jenkins-infra[jenkins-infra GitHub organization]
3333

3434

3535
The following components are out of scope:

‎content/solutions/php.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ file (`phpcs.xml`):
177177
----
178178

179179
You can then fine-tune the failure conditions using the
180-
https://www.jenkins.io/doc/pipeline/steps/warnings-ng/[Warnings-NG pipeline configuration]
180+
link:/doc/pipeline/steps/warnings-ng/[Warnings-NG pipeline configuration]
181181

182182
==== Results Caching
183183

‎content/templates/updates.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ See https://github.com/jenkins-infra/update-center2/tree/master/site[OSS Update
2929
The experimental plugin site is located at https://updates.jenkins.io/experimental/[https://updates.jenkins.io/experimental/].
3030
Configure `+https://updates.jenkins.io/experimental/update-center.json+` in Jenkins to receive experimental releases (those with `alpha` or `beta` in their version numbers).
3131

32-
See https://www.jenkins.io/doc/developer/publishing/releasing-experimental-updates/[Publishing Experimental Plugin Releases] for more information.
32+
See link:/doc/developer/publishing/releasing-experimental-updates/[Publishing Experimental Plugin Releases] for more information.
3333

3434
This update site always serves the latest releases, which may be incompatible with your version of Jenkins.
3535

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
# Report adoc files that use https://www.jenkins.io or https://jenkins.io
4+
5+
# Site development depends on links being relative to the current site
6+
# so that we can show the site on a developer desktop or in the preview
7+
# sites without links that jump to the original site.
8+
9+
# See https://github.com/jenkins-infra/jenkins.io/issues/5718
10+
# See also https://github.com/jenkins-infra/jenkins.io/pull/5715
11+
12+
# Returns 0 if no issues are detected or script is running on trusted.ci.jenkins.io
13+
# Returns 1 if one or more adoc files include https://www.jenkins.io
14+
# Returns 2 if one or more adoc files include https://jenkins.io
15+
# Returns 3 if both https://www.jenkins.io and https://jenkins.io are found
16+
17+
return_code=0
18+
19+
files=$(git grep -l https://www.jenkins.io -- content/[a-zA-Z]**/*.adoc)
20+
if [ "$files" != "" ]; then
21+
echo "ERROR: incorrectly used https://www.jenkins.io in ${files}"
22+
echo
23+
echo "See https://github.com/jenkins-infra/jenkins.io/issues/5718"
24+
echo "See also https://github.com/jenkins-infra/jenkins.io/pull/5715"
25+
echo
26+
return_code=1
27+
fi
28+
29+
files=$(git grep -l https://jenkins.io -- content/[a-zA-Z]**/*.adoc)
30+
if [ "$files" != "" ]; then
31+
echo "ERROR: incorrectly used https://jenkins.io in ${files}"
32+
echo
33+
echo "See https://github.com/jenkins-infra/jenkins.io/issues/5718"
34+
echo "See also https://github.com/jenkins-infra/jenkins.io/pull/5715"
35+
echo
36+
return_code=$(( return_code + 2 ))
37+
fi
38+
39+
exit $return_code

0 commit comments

Comments
 (0)
Please sign in to comment.