Skip to content

Commit a996b00

Browse files
committed
- fixed the jenkins comments by removed the duplicated some fields (id, description) already provided by BaseStandardCredentials.
1 parent 8186ee4 commit a996b00

File tree

5 files changed

+10
-40
lines changed

5 files changed

+10
-40
lines changed

src/main/java/io/jenkins/plugins/vigilnz/build/SecurityCheckBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item project) {
178178
project,
179179
ACL.SYSTEM, // Use actual user authentication, not ACL.SYSTEM
180180
Collections.emptyList())) {
181-
String label = c.getTokenId().isEmpty() ? c.getTokenDescription() : c.getTokenId();
181+
String label = c.getId().isEmpty() ? c.getDescription() : c.getId();
182182
if (label == null || label.isEmpty()) {
183183
label = c.getId();
184184
}

src/main/java/io/jenkins/plugins/vigilnz/credentials/TokenCredentials.java

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,28 @@ public class TokenCredentials extends BaseStandardCredentials {
1818

1919
private final Secret token;
2020

21-
@SuppressWarnings("lgtm[jenkins/plaintext-storage]")
22-
private final String tokenId;
23-
24-
@SuppressWarnings("lgtm[jenkins/plaintext-storage]")
25-
private final String tokenDescription;
26-
2721
@DataBoundConstructor
2822
public TokenCredentials(
2923
CredentialsScope scope,
30-
String tokenId,
31-
String tokenDescription,
24+
String id,
25+
String description,
3226
Secret token
3327
) {
34-
super(scope, tokenId, tokenDescription);
35-
// If tokenId is null or empty, use empty string (Jenkins will handle ID generation)
36-
// This prevents errors when updating credentials that were created without an ID
37-
String idToUse = (tokenId == null || tokenId.trim().isEmpty()) ? "" : tokenId;
28+
super(scope, id, description);
3829

3930
if (token == null || Secret.toString(token).isEmpty()) {
4031
throw new IllegalArgumentException("Token is required");
4132
}
42-
if (tokenId != null && tokenId.contains(" ")) {
43-
throw new IllegalArgumentException("Token ID must not contain spaces");
44-
}
33+
// if (id != null && id.contains(" ")) {
34+
// throw new IllegalArgumentException("Token ID must not contain spaces");
35+
// }
4536
this.token = token;
46-
this.tokenId = idToUse;
47-
this.tokenDescription = tokenDescription;
4837
}
4938

5039
public Secret getToken() {
5140
return token;
5241
}
5342

54-
public String getTokenId() {
55-
// If tokenId was never set by user, return the actual Jenkins-generated ID
56-
if (tokenId == null || tokenId.trim().isEmpty()) {
57-
return getId();
58-
}
59-
return tokenId;
60-
}
61-
62-
public String getTokenDescription() {
63-
return tokenDescription;
64-
}
65-
6643

6744
// Descriptor for Jenkins UI
6845
@Symbol("vigilnzToken")

src/main/resources/io/jenkins/plugins/vigilnz/credentials/TokenCredentials/config.jelly

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
</script>
1616
</f:entry>
1717

18-
<f:entry field="tokenId" title="ID">
18+
<f:entry field="id" title="ID">
1919
<j:choose>
2020
<!-- Existing credential: show read-only with actual Jenkins ID -->
2121
<j:when test="${instance != null}">
2222
<!-- Get the actual ID to display and submit -->
2323
<j:set var="idValue"
24-
value="${instance.tokenId != null and instance.tokenId != '' ? instance.tokenId : instance.id}"/>
24+
value="${instance.id != null and instance.id != '' ? instance.id : instance.id}"/>
2525
<!-- Display as read-only -->
2626
<f:readOnlyTextbox value="${idValue}"/>
2727

@@ -33,7 +33,7 @@
3333
</j:choose>
3434
</f:entry>
3535

36-
<f:entry title="Description" field="tokenDescription">
36+
<f:entry title="Description" field="description">
3737
<f:textbox/>
3838
</f:entry>
3939
</j:jelly>

src/main/resources/io/jenkins/plugins/vigilnz/credentials/TokenCredentials/help-tokenDescription.html

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

src/main/resources/io/jenkins/plugins/vigilnz/credentials/TokenCredentials/help-tokenId.html

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

0 commit comments

Comments
 (0)