jfrog / jenkins-artifactory-plugin

Jenkins artifactory plugin
http://jenkins-ci.org/
116 stars 190 forks source link

artifactory plugin 3.11.0 not compatible with JCasC? #476

Open ewelinawilkosz opened 3 years ago

ewelinawilkosz commented 3 years ago

Describe the bug After upgrading artifactory plugin to version 3.11.0 (and Jenkins to 2.277.4), Jenkins Configuration as Code plugin no longer accept artifactory plugin configuration - it throws a stacktrace

When trying to configure manually, and exporting the configuration (Manage Jenkins > Configuration as Code > View Configuration) I can see errors:

unclassified:
  artifactoryBuilder:
    artifactoryServers: |-
      FAILED TO EXPORT
      org.jfrog.hudson.ArtifactoryBuilder$DescriptorImpl#artifactoryServers: No configurator found for type class org.jfrog.hudson.ArtifactoryServer

with older version, 3.10.6 (Jenkins version 2.277.2) it looks correct:

unclassified:
  artifactoryBuilder:
    artifactoryServers:
    - artifactoryUrl: "http://(...)"
      bypassProxy: false
      connectionRetry: 3
      deployerCredentialsConfig:
(...)

To Reproduce Try to configure artifactory on Jenkins manually and check exported JCasC config

Expected behavior as in a fragment of code shared above

Screenshots n/a

Versions

Additional context n/a

rickbrouwer commented 3 years ago

Same issue at Jenkins 2.293

Or-Geva commented 3 years ago

@ewelinawilkosz & @rickbrouwer, thank you for reporting this. I found the cause of this issue and will keep updating this thread when there will be a fix.

Or-Geva commented 3 years ago

@ewelinawilkosz & @rickbrouwer, Jenkins-Artifactory-Plugin 3.11.1 is released and includes a fix for this issue, feel free to upgrade and share your feedback.

ankithriday commented 3 years ago

@Or-Geva Still seeing the same issue with plugin version 3.11.1

Or-Geva commented 3 years ago

@ankithriday, could you restart your Jenkins after upgrade to 3.11.1? if this does not help, please share more info.

rickbrouwer commented 3 years ago

Upgraded to 3.11.1 (Jenkins 2.290). Works fine, thanks!

thewuffel commented 3 years ago

We have the same issue without JCasC. Try to save a ENV-Var, we get an error from the Jenkins-Artifactory-Plugin 3.11.0 and Jenkins-Artifactory-Plugin 3.11.1 saving our conf and write it to xml.

We use the bypassProxy-Option and it don't write the value of it.

... bypassProxy":{}, ..

Or-Geva commented 3 years ago

Thank you for reporting this issue @thewuffel, I have just created a fix for this. Here is a snapshot that includes the fix, I will appreciate it if you could check if it resolves your issue.

Or-Geva commented 3 years ago

@thewuffel, Jenkins-Artifactory-Plugin 3.11.2 is released and includes the fix for your issue, feel free to upgrade and share your feedback.

rickbrouwer commented 3 years ago

Unfortunately, the issue is back. The update (Jenkins 2.295) is installed yesterday evening (3.11.2) automatically. Jenkins can't start:

io.jenkins.plugins.casc.ConfiguratorException: Cannot find configurator for type class org.jfrog.hudson.ArtifactoryServer at io.jenkins.plugins.casc.impl.DefaultConfiguratorRegistry.lookupOrFail(DefaultConfiguratorRegistry.java:69) at io.jenkins.plugins.casc.ConfigurationContext.lookupOrFail(ConfigurationContext.java:112) at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:337) at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:287) at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:351) at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:287) at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$8(ConfigurationAsCode.java:777) at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:713) Caused: io.jenkins.plugins.casc.ConfiguratorException: unclassified: error configuring 'unclassified' with class io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator configurator at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:719) at io.jenkins.plugins.casc.ConfigurationAsCode.checkWith(ConfigurationAsCode.java:777) at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:762) at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:638) at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:307) at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:299) Caused: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:105) Caused: java.lang.Error at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:111) at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:181) at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296) at jenkins.model.Jenkins$5.runTask(Jenkins.java:1161) at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214) at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117) at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused: org.jvnet.hudson.reactor.ReactorException at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282) at jenkins.InitReactorRunner.run(InitReactorRunner.java:50) at jenkins.model.Jenkins.executeReactor(Jenkins.java:1194) at jenkins.model.Jenkins.<init>(Jenkins.java:992) at hudson.model.Hudson.<init>(Hudson.java:86) at hudson.model.Hudson.<init>(Hudson.java:82) at hudson.WebAppMain$3.run(WebAppMain.java:298) Caused: hudson.util.HudsonFailedToLoad at hudson.WebAppMain$3.run(WebAppMain.java:315)

ewelinawilkosz commented 3 years ago

isn't that upcoming PR on JCasC documentation addressing the same problem from another side: https://github.com/jenkinsci/configuration-as-code-plugin/pull/1608/files ?

field name/syntax has changed, I believe

this issue was raised mainly to address stacktrace in JCasC configuration generation, since it worked before I haven't had time to very version 3.11.0 yet, but @rickbrouwer maybe you need to update your configuration in order to make the new verion works? maybe :)

would be nice to hear if you managed to make it work

liejuntao001 commented 3 years ago

I had the same issue. Need update the JCasC config to make it work

-            artifactoryServers:
+            jfrogInstances:
-              serverId: "artifact.xxxx"
+              instanceId: "artifact.xxxx"
ysmaoui commented 3 years ago

thanks @liejuntao001

the artifactoyBuilder properties changed

This is an extract of the Jenkins CasC json schema

                "artifactoryBuilder": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                        "useCredentialsPlugin": {
                            "description": "",
                            "type": "boolean"
                        },
                        "jfrogPipelinesServer": {
                            "description": "",
                            "additionalProperties": false,
                            "type": "object",
                            "$id": "#/definitions/org.jfrog.hudson.jfpipelines.JFrogPipelinesServer"
                        },
                        "jfrogInstances": {
                            "description": "",
                            "type": "array",
                            "items": [{
                                "additionalProperties": false,
                                "type": "object",
                                "properties": {
                                    "deployerCredentialsConfig": {
                                        "description": "",
                                        "additionalProperties": false,
                                        "type": "object",
                                        "$id": "#/definitions/org.jfrog.hudson.CredentialsConfig"
                                    },
                                    "instanceId": {
                                        "description": "",
                                        "type": "string"
                                    },
                                    "platformUrl": {
                                        "description": "",
                                        "type": "string"
                                    },
                                    "artifactoryUrl": {
                                        "description": "",
                                        "type": "string"
                                    },
                                    "deploymentThreads": {
                                        "description": "",
                                        "type": "integer"
                                    },
                                    "bypassProxy": {
                                        "description": "",
                                        "type": "boolean"
                                    },
                                    "connectionRetry": {
                                        "description": "",
                                        "type": "integer"
                                    },
                                    "resolverCredentialsConfig": {
                                        "description": "",
                                        "additionalProperties": false,
                                        "type": "object",
                                        "$id": "#/definitions/org.jfrog.hudson.CredentialsConfig"
                                    },
                                    "timeout": {
                                        "description": "",
                                        "type": "integer"
                                    },
                                    "url": {
                                        "description": "",
                                        "type": "string"
                                    }
                                }
                            }]
                        }
                    }
                }
rickbrouwer commented 3 years ago

isn't that upcoming PR on JCasC documentation addressing the same problem from another side: https://github.com/jenkinsci/configuration-as-code-plugin/pull/1608/files ?

field name/syntax has changed, I believe

this issue was raised mainly to address stacktrace in JCasC configuration generation, since it worked before I haven't had time to very version 3.11.0 yet, but @rickbrouwer maybe you need to update your configuration in order to make the new verion works? maybe :)

would be nice to hear if you managed to make it work

Yes. Works, thanks!