Skip to content

Predictable Snippetizer output for LibraryStep#215

Merged
jglick merged 2 commits intojenkinsci:masterfrom
jglick:SCMSource.id
Nov 14, 2025
Merged

Predictable Snippetizer output for LibraryStep#215
jglick merged 2 commits intojenkinsci:masterfrom
jglick:SCMSource.id

Conversation

@jglick
Copy link
Member

@jglick jglick commented Nov 14, 2025

@jglick jglick added the bug Something isn't working label Nov 14, 2025
UninstantiatedDescribable scmUd = (UninstantiatedDescribable) scm;
Map<String, Object> scmArguments = new HashMap<>(scmUd.getArguments());
if (scm instanceof UninstantiatedDescribable scmUd) {
Map<String, Object> scmArguments = new LinkedHashMap<>(scmUd.getArguments());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main change.

if (scm instanceof UninstantiatedDescribable) {
UninstantiatedDescribable scmUd = (UninstantiatedDescribable) scm;
Map<String, Object> scmArguments = new HashMap<>(scmUd.getArguments());
if (scm instanceof UninstantiatedDescribable scmUd) {
Copy link
Member Author

@jglick jglick Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java 17 or whatever it is

Map<String, Object> scmArguments = new LinkedHashMap<>(scmUd.getArguments());
scmArguments.remove("id");
Map<String, Object> retrieverArguments = new HashMap<>(ud.getArguments());
Map<String, Object> retrieverArguments = new LinkedHashMap<>(ud.getArguments());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just in case

// TODO uninstantiate works but SnippetizerTester.assertRoundTrip fails due to differing SCMSource.id values
assertEquals("library identifier: 'foo@master', retriever: modernSCM(gitSource(traits: [gitBranchDiscovery()], credentialsId: '', remote: 'https://nowhere.net/'))", Snippetizer.object2Groovy(s));
// TODO uninstantiate works but SnippetizerTester.assertRoundTrip fails due to differing SCMSource.id values pending https://github.com/jenkinsci/scm-api-plugin/pull/357
assertEquals("library identifier: 'foo@master', retriever: modernSCM(gitSource(credentialsId: '', remote: 'https://nowhere.net/', traits: [gitBranchDiscovery()]))", Snippetizer.object2Groovy(s));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now alphabetized as expected: credentials remote traits

@jglick jglick requested a review from dwnusbaum November 14, 2025 19:36
@jglick jglick marked this pull request as ready for review November 14, 2025 20:45
@jglick jglick requested a review from a team as a code owner November 14, 2025 20:45
@jglick jglick enabled auto-merge November 14, 2025 20:45
@jglick jglick merged commit e2fef0e into jenkinsci:master Nov 14, 2025
18 of 19 checks passed
@jglick jglick deleted the SCMSource.id branch November 14, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants