question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Classes with Same name and Different Packages are being triggered - AzureCredentials

See original GitHub issue
  • [X ] Jenkins version 2.187

    [X] Plugin version -configuration-as-code:1.24 && configuration-as-code-support:1.18

  • OS - Alpine (Docker Official Image)

Description

When using Azure Credentials with CASC references to Azure Credentials ( plugin azure-credentials:1.6.1 ) get caught by a different package

Example for CASC confs

        - azure:
            clientId: "${azure_clientId}"
            clientSecret: "${azure_clientSecret}"
            description: "Azure Credentials"
            id: "X"
            scope: GLOBAL
            subscriptionId: "${azure_subscriptionId}"
            azureEnvironmentName: "Azure"

This results in:

jenkins_1                 | io.jenkins.plugins.casc.ConfiguratorException: Invalid configuration elements for type class com.microsoftopentechnologies.windowsazurestorage.helper.AzureCredentials : azureEnvironmentName,clientId,clientSecret,subscriptionId,tenant.
jenkins_1                 | Available attributes : blobEndpointURL, description, id, scope, storageAccountName, storageKey
jenkins_1                 |     at io.jenkins.plugins.casc.BaseConfigurator.handleUnknown(BaseConfigurator.java:378)
jenkins_1                 |     at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:367)
jenkins_1                 |     at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:277)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.configure(DataBoundConfigurator.java:83)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$doConfigure$16668e2$1(HeteroDescribableConfigurator.java:278)
jenkins_1                 |     at io.vavr.CheckedFunction0.lambda$unchecked$52349c75$1(CheckedFunction0.java:201)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.doConfigure(HeteroDescribableConfigurator.java:278)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$null$2(HeteroDescribableConfigurator.java:86)
jenkins_1                 |     at io.vavr.control.Option.map(Option.java:373)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$configure$3(HeteroDescribableConfigurator.java:86)
jenkins_1                 |     at io.vavr.Tuple2.apply(Tuple2.java:239)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.configure(HeteroDescribableConfigurator.java:83)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.configure(HeteroDescribableConfigurator.java:55)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:153)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.instance(DataBoundConfigurator.java:77)
jenkins_1                 |     at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:268)
jenkins_1                 |     at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.check(DataBoundConfigurator.java:101)
jenkins_1                 |     at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:345)
jenkins_1                 |     at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:288)
jenkins_1                 |     at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:353)
jenkins_1                 |     at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:288)
jenkins_1                 |     at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$6(ConfigurationAsCode.java:684)
jenkins_1                 |     at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:646)
jenkins_1                 | Caused: io.jenkins.plugins.casc.ConfiguratorException: credentials: error configuring 'credentials' with class com.cloudbees.plugins.credentials.casc.CredentialsRootConfigurator configurator
jenkins_1                 |     at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:652)
jenkins_1                 |     at io.jenkins.plugins.casc.ConfigurationAsCode.checkWith(ConfigurationAsCode.java:684)
jenkins_1                 |     at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:668)
jenkins_1                 |     at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:567)
jenkins_1                 |     at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:280)
jenkins_1                 |     at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:272)
jenkins_1                 | Caused: java.lang.reflect.InvocationTargetException
jenkins_1                 |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jenkins_1                 |     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
jenkins_1                 |     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
jenkins_1                 |     at java.lang.reflect.Method.invoke(Method.java:498)
jenkins_1                 |     at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
jenkins_1                 | Caused: java.lang.Error
jenkins_1                 |     at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
jenkins_1                 |     at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
jenkins_1                 |     at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
jenkins_1                 |     at jenkins.model.Jenkins$5.runTask(Jenkins.java:1118)
jenkins_1                 |     at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
jenkins_1                 |     at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
jenkins_1                 |     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
jenkins_1                 |     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
jenkins_1                 |     at java.lang.Thread.run(Thread.java:748)

The same is valid if we set Azure Storage Credentials

        - azureStorageAccount:
            blobEndpointURL: "https://blob.core.windows.net/"
            id: "X-Storage"
            scope: GLOBAL
            storageAccountName: "${azure_storageAccountName}"
            storageKey: "${azure_storageKey}"
        - azure:
            clientId: "${azure_clientId}"
            clientSecret: "${azure_clientSecret}"
            description: "Azure Credentials"
            id: "X"
            scope: GLOBAL
            subscriptionId: "${azure_subscriptionId}"
            azureEnvironmentName: "Azure"

The values for azureStorageAccount have been exported from CASC to check if setting it would not trigger this bug.

The above results in triggering twice the Same StackTrace as set above.

Notice the package used: com.microsoftopentechnologies.windowsazurestorage.helper.AzureCredentials

It should in fact call the one below: com.microsoft.azure.util.AzureCredentials

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
timjacommented, Jul 29, 2019

I hacked around it in a PR to this plugin and set a symbol: https://github.com/jenkinsci/windows-azure-storage-plugin/blob/dev/src/main/java/com/microsoftopentechnologies/windowsazurestorage/helper/AzureCredentials.java

but yeah it’s bad class design which is causing this problem, not related to JCASC, should create an issue on jira. @gavinfish FYI

1reaction
gavinfishcommented, Jul 29, 2019

@Ilhicas please feel free to open a ticket on Jira and I will follow up, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Same class name in different packages - java - Stack Overflow
Yes, you can have two classes with the same name in multiple packages. However, you can't import both classes in the same file...
Read more >
Create transfers | Cloud Storage Transfer Service ...
To specify a Cloud Storage bucket from another project, type the name exactly ... Excludes files from the transfer based on a name...
Read more >
Use system-assigned managed identities to access Azure ...
In this step, you'll assign a role to the function app's system-assigned managed identity. Azure Cosmos DB has multiple built-in roles that you ......
Read more >
How to deal with Classes having the same name (different ...
As you can guess, the names conflict when both classes are referenced in the same Java file. For example: com.myapp.model (package) - Device...
Read more >
DefaultAzureIdentity And Its Various Credential Types
This article shows various ways to retrieve an Azure identity from an ... DefaultAzureCredential combines some classes, that are used to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found