Skip to content

Commit 7777ec9

Browse files
Merge pull request #1 from jenkinsci/setting-up-release
Setting up release
2 parents bd23366 + 5b72391 commit 7777ec9

File tree

10 files changed

+142
-82
lines changed

10 files changed

+142
-82
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ updates:
99
- package-ecosystem: github-actions
1010
directory: /
1111
schedule:
12-
interval: monthly
12+
interval: monthly

.github/release-drafter.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/cd.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Note: additional setup is required, see https://www.jenkins.io/redirect/continuous-delivery-of-plugins
2+
#
3+
# Please find additional hints for individual trigger use case
4+
# configuration options inline this script below.
5+
#
6+
name: cd
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
validate_only:
11+
required: false
12+
type: boolean
13+
description: |
14+
Run validation with release drafter only
15+
→ Skip the release job
16+
# Note: Change this default to true,
17+
# if the checkbox should be checked by default.
18+
default: false
19+
# If you don't want any automatic trigger in general, then
20+
# the following check_run trigger lines should all be commented.
21+
# Note: Consider the use case #2 config for 'validate_only' below
22+
# as an alternative option!
23+
check_run:
24+
types:
25+
- completed
26+
27+
permissions:
28+
checks: read
29+
contents: write
30+
31+
jobs:
32+
maven-cd:
33+
uses: jenkins-infra/github-reusable-workflows/.github/workflows/maven-cd.yml@v1
34+
with:
35+
# Comment / uncomment the validate_only config appropriate to your preference:
36+
#
37+
# Use case #1 (automatic release):
38+
# - Let any successful Jenkins build trigger another release,
39+
# if there are merged pull requests of interest
40+
# - Perform a validation only run with drafting a release note,
41+
# if manually triggered AND inputs.validate_only has been checked.
42+
#
43+
validate_only: ${{ inputs.validate_only == true }}
44+
#
45+
# Alternative use case #2 (no automatic release):
46+
# - Same as use case #1 - but:
47+
# - Let any check_run trigger a validate_only run.
48+
# => enforce the release job to be skipped.
49+
#
50+
#validate_only: ${{ inputs.validate_only == true || github.event_name == 'check_run' }}
51+
secrets:
52+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
53+
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}

.github/workflows/release-drafter.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.mvn/extensions.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
2+
<extension>
3+
<groupId>io.jenkins.tools.incrementals</groupId>
4+
<artifactId>git-changelist-maven-extension</artifactId>
5+
<version>1.7</version>
6+
</extension>
7+
</extensions>

.mvn/maven.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-Pconsume-incrementals
2+
-Pmight-produce-incrementals
3+
-Dchangelist.format=%d.v%s

pom.xml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<groupId>io.jenkins.plugins</groupId>
1313
<artifactId>cloudaeye</artifactId>
14-
<version>${revision}${changelist}</version>
14+
<version>${changelist}</version>
1515
<packaging>hpi</packaging>
1616

1717
<name>CloudAEye Plugin</name>
@@ -30,9 +30,7 @@
3030
</scm>
3131

3232
<properties>
33-
<revision>1.0.0</revision>
34-
<changelist>-SNAPSHOT</changelist>
35-
33+
<changelist>999999-SNAPSHOT</changelist>
3634
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
3735
<jenkins.version>2.440.3</jenkins.version>
3836
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
@@ -66,20 +64,20 @@
6664

6765
<dependencies>
6866

69-
<!-- Jenkins Workflow Job Plugin -->
70-
<dependency>
71-
<groupId>org.jenkins-ci.plugins.workflow</groupId>
72-
<artifactId>workflow-job</artifactId>
73-
<version>1400.v7fd111b_ec82f</version>
74-
</dependency>
75-
7667
<!-- Git Plugin -->
7768
<dependency>
7869
<groupId>org.jenkins-ci.plugins</groupId>
7970
<artifactId>git</artifactId>
8071
<version>5.2.2</version>
8172
</dependency>
8273

74+
<!-- Jenkins Workflow Job Plugin -->
75+
<dependency>
76+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
77+
<artifactId>workflow-job</artifactId>
78+
<version>1400.v7fd111b_ec82f</version>
79+
</dependency>
80+
8381
</dependencies>
8482

8583
<repositories>

src/main/java/io/jenkins/plugins/cloudaeye/CloudAEyeGlobalKeyConfiguration.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
import hudson.ExtensionList;
66
import hudson.util.FormValidation;
77
import hudson.util.Secret;
8+
import java.io.IOException;
9+
import java.text.MessageFormat;
10+
import java.util.logging.Logger;
11+
import javax.servlet.ServletException;
812
import jenkins.model.GlobalConfiguration;
13+
import jenkins.model.Jenkins;
914
import org.apache.commons.lang.StringUtils;
1015
import org.apache.http.HttpResponse;
1116
import org.apache.http.util.EntityUtils;
1217
import org.kohsuke.stapler.DataBoundSetter;
1318
import org.kohsuke.stapler.QueryParameter;
1419
import org.kohsuke.stapler.verb.POST;
1520

16-
import javax.servlet.ServletException;
17-
import java.io.IOException;
18-
import java.text.MessageFormat;
19-
import java.util.logging.Logger;
20-
2121
/**
2222
* Handles the global key configuration for the plugin
2323
*/
@@ -65,11 +65,15 @@ public void setToken(Secret token) {
6565
* @return Valid form
6666
*/
6767
public FormValidation doCheckTenantKey(@QueryParameter String tenantKey) {
68+
if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
69+
return FormValidation.ok();
70+
}
6871
if (StringUtils.isEmpty(tenantKey)) {
6972
return FormValidation.warning("Please specify a valid tenant key");
7073
}
7174
return FormValidation.ok();
7275
}
76+
7377
public FormValidation doCheckToken(@QueryParameter String token) {
7478
if (StringUtils.isEmpty(token)) {
7579
return FormValidation.warning("Please provide a valid token");
@@ -86,26 +90,29 @@ public FormValidation doCheckToken(@QueryParameter String token) {
8690
* @throws ServletException
8791
*/
8892
@POST
89-
public FormValidation doTestConnection(@QueryParameter("tenantKey") final Secret tenantKey,
90-
@QueryParameter("token") final Secret token) throws IOException, ServletException {
93+
public FormValidation doTestConnection(
94+
@QueryParameter("tenantKey") final Secret tenantKey, @QueryParameter("token") final Secret token)
95+
throws IOException, ServletException {
9196
try {
9297
// Convert the details to string
9398
JsonObject ping = new JsonObject();
9499
ping.addProperty("ping", true);
95100
LOGGER.fine(MessageFormat.format("[#{0}] Ping payload : {1}", tenantKey, ping.toString()));
96101
NotificationSender notificationSender = new NotificationSender();
97-
HttpResponse response = notificationSender.sendDetailsToCloudAEye(ping.toString(),tenantKey,token);
102+
HttpResponse response = notificationSender.sendDetailsToCloudAEye(ping.toString(), tenantKey, token);
98103
if (response.getStatusLine().getStatusCode() == 200) {
99104
LOGGER.fine(MessageFormat.format("[#{0}] Ping successful", tenantKey));
100105
return FormValidation.ok("Connection successful!");
101106
} else {
102-
LOGGER.fine(MessageFormat.format("[#{0}] Ping failed : {1}", tenantKey, EntityUtils.toString(response.getEntity())));
103-
return FormValidation.error("Connection failed! Got response: " + EntityUtils.toString(response.getEntity()));
107+
LOGGER.fine(MessageFormat.format(
108+
"[#{0}] Ping failed : {1}", tenantKey, EntityUtils.toString(response.getEntity())));
109+
return FormValidation.error(
110+
"Connection failed! Got response: " + EntityUtils.toString(response.getEntity()));
104111
}
105112
} catch (IOException e) {
106-
LOGGER.fine(MessageFormat.format("[#{0}] Error while trying to ping CloudAEye webhook endpoint : {1}", tenantKey, e.getMessage()));
113+
LOGGER.fine(MessageFormat.format(
114+
"[#{0}] Error while trying to ping CloudAEye webhook endpoint : {1}", tenantKey, e.getMessage()));
107115
return FormValidation.error("Error while trying to ping CloudAEye webhook endpoint : " + e.getMessage());
108116
}
109117
}
110-
111118
}

0 commit comments

Comments
 (0)