Skip to content

Commit e712a04

Browse files
[JENKINS-26585] - Two new variants to show also direct link to job without view in URL
1 parent 1345594 commit e712a04

File tree

4 files changed

+122
-42
lines changed

4 files changed

+122
-42
lines changed

src/main/resources/org/jenkinsci/plugins/badge/BadgeAction/index.groovy

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,44 +30,79 @@ l.layout {
3030
</style>
3131
""")
3232

33-
def base = "${app.rootUrl}${my.project.url}";
34-
def badge = base + "badge/icon"
35-
3633
def fullJobName = h.escape(my.project.fullName);
37-
def publicbadge = "${app.rootUrl}buildStatus/icon?job=${fullJobName}";
34+
def jobUrlWithView = "${app.rootUrl}${my.project.url}";
35+
def jobUrlWithoutView = "${app.rootUrl}job/${fullJobName}";
36+
def badgeUrlWithView = jobUrlWithView + "badge/icon"
37+
def badgeUrlWithoutView = jobUrlWithoutView + "/badge/icon"
38+
def publicBadge = "${app.rootUrl}buildStatus/icon?job=${fullJobName}";
39+
40+
3841
h3 {
3942
text(_("Image"))
40-
img(id:"badge",src:badge)
43+
img(id:"badgeUrlWithView",src:badgeUrlWithView)
4144
text(_(" or "))
42-
img(src:badge + "?style=plastic")
45+
img(src:badgeUrlWithView + "?style=plastic")
4346
}
47+
48+
h3(_("Plain Link (with view)"))
49+
b {text(_("protected"))}
50+
input(type:"text",value:badgeUrlWithView,class:"select-all")
51+
b {text(_("unprotected"))}
52+
input(type:"text",value:publicBadge,class:"select-all")
53+
54+
h3(_("Plain Link (without view)"))
55+
b {text(_("protected"))}
56+
input(type:"text",value:badgeUrlWithoutView,class:"select-all")
57+
b {text(_("unprotected"))}
58+
input(type:"text",value:publicBadge,class:"select-all")
59+
60+
h3(_("Markdown (with view)"))
61+
b {text(_("protected"))}
62+
input(type:"text",value:"[![Build Status](${badgeUrlWithView})](${jobUrlWithView})",class:"select-all")
63+
b {text(_("unprotected"))}
64+
input(type:"text",value:"[![Build Status](${publicBadge})](${jobUrlWithView})",class:"select-all")
65+
66+
h3(_("Markdown (without view)"))
67+
b {text(_("protected"))}
68+
input(type:"text",value:"[![Build Status](${badgeUrlWithoutView})](${jobUrlWithoutView})",class:"select-all")
69+
b {text(_("unprotected"))}
70+
input(type:"text",value:"[![Build Status](${publicBadge})](${jobUrlWithoutView})",class:"select-all")
71+
72+
h3(_("HTML (with view)"))
73+
b {text(_("protected"))}
74+
input(type:"text",value:"<a href='${jobUrlWithView}'><img src='${badgeUrlWithView}'></a>",class:"select-all")
75+
b {text(_("unprotected"))}
76+
input(type:"text",value:"<a href='${jobUrlWithView}'><img src='${publicBadge}'></a>",class:"select-all")
77+
78+
h3(_("HTML (without view)"))
4479
b {text(_("protected"))}
45-
input(type:"text",value:badge,class:"select-all")
80+
input(type:"text",value:"<a href='${jobUrlWithoutView}'><img src='${badgeUrlWithoutView}'></a>",class:"select-all")
4681
b {text(_("unprotected"))}
47-
input(type:"text",value:publicbadge,class:"select-all")
82+
input(type:"text",value:"<a href='${jobUrlWithoutView}'><img src='${publicBadge}'></a>",class:"select-all")
4883

49-
h3(_("Markdown"))
84+
h3(_("Confluence (with view)"))
5085
b {text(_("protected"))}
51-
input(type:"text",value:"[![Build Status](${badge})](${base})",class:"select-all")
86+
input(type:"text",value:"[!${badgeUrlWithView}!|${jobUrlWithView}]",class:"select-all")
5287
b {text(_("unprotected"))}
53-
input(type:"text",value:"[![Build Status](${publicbadge})](${base})",class:"select-all")
88+
input(type:"text",value:"[!${publicBadge}!|${jobUrlWithView}]",class:"select-all")
5489

55-
h3(_("HTML"))
90+
h3(_("Confluence (without view)"))
5691
b {text(_("protected"))}
57-
input(type:"text",value:"<a href='${base}'><img src='${badge}'></a>",class:"select-all")
92+
input(type:"text",value:"[!${badgeUrlWithoutView}!|${jobUrlWithoutView}]",class:"select-all")
5893
b {text(_("unprotected"))}
59-
input(type:"text",value:"<a href='${base}'><img src='${publicbadge}'></a>",class:"select-all")
94+
input(type:"text",value:"[!${publicBadge}!|${jobUrlWithoutView}]",class:"select-all")
6095

61-
h3(_("Confluence"))
96+
h3(_("XWiki (with view)"))
6297
b {text(_("protected"))}
63-
input(type:"text",value:"[!${badge}!|${base}]",class:"select-all")
98+
input(type:"text",value:"[[image:${badgeUrlWithView}>>${jobUrlWithView}||target='__new']]",class:"select-all")
6499
b {text(_("unprotected"))}
65-
input(type:"text",value:"[!${publicbadge}!|${base}]",class:"select-all")
100+
input(type:"text",value:"[[image:${publicBadge}>>${jobUrlWithView}||target='__new']]",class:"select-all")
66101

67-
h3(_("XWiki"))
102+
h3(_("XWiki (without view)"))
68103
b {text(_("protected"))}
69-
input(type:"text",value:"[[image:${badge}>>${base}||target='__new']]",class:"select-all")
104+
input(type:"text",value:"[[image:${badgeUrlWithoutView}>>${jobUrlWithoutView}||target='__new']]",class:"select-all")
70105
b {text(_("unprotected"))}
71-
input(type:"text",value:"[[image:${publicbadge}>>${base}||target='__new']]",class:"select-all")
106+
input(type:"text",value:"[[image:${publicBadge}>>${jobUrlWithoutView}||target='__new']]",class:"select-all")
72107
}
73108
}

src/main/resources/org/jenkinsci/plugins/badge/BadgeAction/index.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
blurb=Jenkins exposes the current status of your build as an image in a fixed URL. \
22
You can put this URL into other sites (such as GitHub README) so that people \
3-
can see the current state of the build. <br>There are two URLs available for inclusion: <br> \
3+
can see the current state of the build. <br>There are two variants available for inclusion: <br> \
4+
<ul> \
5+
<li><b>with view</b> includes the current view into the URL.</li> \
6+
<li><b>without view</b> contains the direct path to the job excluding the current view</li> \
7+
</ul> \
8+
<br>For each variant there are two URLs available for inclusion: <br> \
49
<ul> \
510
<li><b>protected</b> exposes the badge to users having at least 'Read' permission on the job</li> \
611
<li><b>unprotected</b> exposes the badge to users having at least 'ViewStatus' permission on the job</li> \

src/main/resources/org/jenkinsci/plugins/badge/RunBadgeAction/index.groovy

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,44 +30,79 @@ l.layout {
3030
</style>
3131
""")
3232

33-
def base = "${app.rootUrl}${my.project.url}${my.run.number}/";
34-
def badge = base + "badge/icon"
35-
3633
def fullJobName = h.escape(my.project.fullName);
37-
def publicbadge = "${app.rootUrl}buildStatus/icon?job=${fullJobName}&build=${my.run.number}";
34+
def jobUrlWithView = "${app.rootUrl}${my.project.url}${my.run.number}/";
35+
def jobUrlWithoutView = "${app.rootUrl}job/${fullJobName}/${my.run.number}/";
36+
def badgeUrlWithView = jobUrlWithView + "badge/icon"
37+
def badgeUrlWithoutView = jobUrlWithoutView + "/badge/icon"
38+
def publicBadge = "${app.rootUrl}buildStatus/icon?job=${fullJobName}&build=${my.run.number}";
39+
3840
h3 {
3941
text(_("Image"))
40-
img(id:"badge",src:badge)
42+
img(id:"badgeUrlWithView",src:badgeUrlWithView)
4143
text(_(" or "))
42-
img(src:badge + "?style=plastic")
44+
img(src:badgeUrlWithView + "?style=plastic")
4345
}
46+
47+
h3(_("Plain Link (with view)"))
48+
b {text(_("protected"))}
49+
input(type:"text",value:badgeUrlWithView,class:"select-all")
50+
b {text(_("unprotected"))}
51+
input(type:"text",value:publicBadge,class:"select-all")
52+
53+
h3(_("Plain Link (without view)"))
54+
b {text(_("protected"))}
55+
input(type:"text",value:badgeUrlWithoutView,class:"select-all")
56+
b {text(_("unprotected"))}
57+
input(type:"text",value:publicBadge,class:"select-all")
58+
59+
60+
h3(_("Markdown (with view)"))
61+
b {text(_("protected"))}
62+
input(type:"text",value:"[![Build Status](${badgeUrlWithView})](${jobUrlWithView})",class:"select-all")
63+
b {text(_("unprotected"))}
64+
input(type:"text",value:"[![Build Status](${publicBadge})](${jobUrlWithView})",class:"select-all")
65+
66+
h3(_("Markdown (without view)"))
67+
b {text(_("protected"))}
68+
input(type:"text",value:"[![Build Status](${badgeUrlWithoutView})](${jobUrlWithoutView})",class:"select-all")
69+
b {text(_("unprotected"))}
70+
input(type:"text",value:"[![Build Status](${publicBadge})](${jobUrlWithoutView})",class:"select-all")
71+
72+
h3(_("HTML (with view)"))
73+
b {text(_("protected"))}
74+
input(type:"text",value:"<a href='${jobUrlWithView}'><img src='${badgeUrlWithView}'></a>",class:"select-all")
75+
b {text(_("unprotected"))}
76+
input(type:"text",value:"<a href='${jobUrlWithView}'><img src='${publicBadge}'></a>",class:"select-all")
77+
78+
h3(_("HTML (without view)"))
4479
b {text(_("protected"))}
45-
input(type:"text",value:badge,class:"select-all")
80+
input(type:"text",value:"<a href='${jobUrlWithoutView}'><img src='${badgeUrlWithoutView}'></a>",class:"select-all")
4681
b {text(_("unprotected"))}
47-
input(type:"text",value:publicbadge,class:"select-all")
82+
input(type:"text",value:"<a href='${jobUrlWithoutView}'><img src='${publicBadge}'></a>",class:"select-all")
4883

49-
h3(_("Markdown"))
84+
h3(_("Confluence (with view)"))
5085
b {text(_("protected"))}
51-
input(type:"text",value:"[![Build Status](${badge})](${base})",class:"select-all")
86+
input(type:"text",value:"[!${badgeUrlWithView}!|${jobUrlWithView}]",class:"select-all")
5287
b {text(_("unprotected"))}
53-
input(type:"text",value:"[![Build Status](${publicbadge})](${base})",class:"select-all")
88+
input(type:"text",value:"[!${publicBadge}!|${jobUrlWithView}]",class:"select-all")
5489

55-
h3(_("HTML"))
90+
h3(_("Confluence (without view)"))
5691
b {text(_("protected"))}
57-
input(type:"text",value:"<a href='${base}'><img src='${badge}'></a>",class:"select-all")
92+
input(type:"text",value:"[!${badgeUrlWithoutView}!|${jobUrlWithoutView}]",class:"select-all")
5893
b {text(_("unprotected"))}
59-
input(type:"text",value:"<a href='${base}'><img src='${publicbadge}'></a>",class:"select-all")
94+
input(type:"text",value:"[!${publicBadge}!|${jobUrlWithoutView}]",class:"select-all")
6095

61-
h3(_("Confluence"))
96+
h3(_("XWiki (with view)"))
6297
b {text(_("protected"))}
63-
input(type:"text",value:"[!${badge}!|${base}]",class:"select-all")
98+
input(type:"text",value:"[[image:${badgeUrlWithView}>>${jobUrlWithView}||target='__new']]",class:"select-all")
6499
b {text(_("unprotected"))}
65-
input(type:"text",value:"[!${publicbadge}!|${base}]",class:"select-all")
100+
input(type:"text",value:"[[image:${publicBadge}>>${jobUrlWithView}||target='__new']]",class:"select-all")
66101

67-
h3(_("XWiki"))
102+
h3(_("XWiki (without view)"))
68103
b {text(_("protected"))}
69-
input(type:"text",value:"[[image:${badge}>>${base}||target='__new']]",class:"select-all")
104+
input(type:"text",value:"[[image:${badgeUrlWithoutView}>>${jobUrlWithoutView}||target='__new']]",class:"select-all")
70105
b {text(_("unprotected"))}
71-
input(type:"text",value:"[[image:${publicbadge}>>${base}||target='__new']]",class:"select-all")
106+
input(type:"text",value:"[[image:${publicBadge}>>${jobUrlWithoutView}||target='__new']]",class:"select-all")
72107
}
73108
}

src/main/resources/org/jenkinsci/plugins/badge/RunBadgeAction/index.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
blurb=Jenkins exposes the status of the specific build as an image in a fixed URL. \
22
You can put this URL into other sites (such as GitHub README) so that people \
3-
can see the state of the specific build. <br>There are two URLs available for inclusion: <br> \
3+
can see the state of the specific build. <br>There are two variants available for inclusion: <br> \
4+
<ul> \
5+
<li><b>with view</b> includes the current view into the URL.</li> \
6+
<li><b>without view</b> contains the direct path to the build excluding the current view</li> \
7+
</ul> \
8+
<br>For each variant there are two URLs available for inclusion: <br> \
49
<ul> \
510
<li><b>protected</b> exposes the badge to users having at least 'Read' permission on the job</li> \
611
<li><b>unprotected</b> exposes the badge to users having at least 'ViewStatus' permission on the job</li> \

0 commit comments

Comments
 (0)