{"action":"created","issue":{"url":"https://api.github.com/repos/jenkinsci/configuration-as-code-plugin/issues/884","repository_url":"https://api.github.com/repos/jenkinsci/configuration-as-code-plugin","labels_url":"https://api.github.com/repos/jenkinsci/configuration-as-code-plugin/issues/884/labels{/name}","comments_url":"https://api.github.com/repos/jenkinsci/configuration-as-code-plugin/issues/884/comments","events_url":"https://api.github.com/repos/jenkinsci/configuration-as-code-plugin/issues/884/events","html_url":"https://github.com/jenkinsci/configuration-as-code-plugin/issues/884","id":445094652,"node_id":"MDU6SXNzdWU0NDUwOTQ2NTI=","number":884,"title":"File credentials' secretBytes doesn't get replaced","user":{"login":"dev-dsp","id":4235552,"node_id":"MDQ6VXNlcjQyMzU1NTI=","avatar_url":"https://avatars1.githubusercontent.com/u/4235552?v=4","gravatar_id":"","url":"https://api.github.com/users/dev-dsp","html_url":"https://github.com/dev-dsp","followers_url":"https://api.github.com/users/dev-dsp/followers","following_url":"https://api.github.com/users/dev-dsp/following{/other_user}","gists_url":"https://api.github.com/users/dev-dsp/gists{/gist_id}","starred_url":"https://api.github.com/users/dev-dsp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dev-dsp/subscriptions","organizations_url":"https://api.github.com/users/dev-dsp/orgs","repos_url":"https://api.github.com/users/dev-dsp/repos","events_url":"https://api.github.com/users/dev-dsp/events{/privacy}","received_events_url":"https://api.github.com/users/dev-dsp/received_events","type":"User","site_admin":false},"labels":[{"id":834893460,"node_id":"MDU6TGFiZWw4MzQ4OTM0NjA=","url":"https://api.github.com/repos/jenkinsci/configuration-as-code-plugin/labels/bug","name":"bug","color":"D73A4A","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2019-05-16T18:18:28Z","updated_at":"2019-05-17T11:21:59Z","closed_at":null,"author_association":"NONE","body":"CWP config sample (there are lots of plugins there, all of them have latest version):\r\n```\r\nbundle:\r\n  groupId: \"com.devops.demo\"\r\n  artifactId: \"some-ci\"\r\n  vendor: \"DevOps\"\r\n  title: \"Configuration-as-Code demo\"\r\n  description: \"Configuration-as-Code demo, produced by Custom WAR Packager\"\r\nbuildSettings:\r\n  docker:\r\n    base: \"jenkins/jenkins:2.164.3\"\r\n    tag: \"some-ci\"\r\n    build: true\r\nwar:\r\n  groupId: \"org.jenkins-ci.main\"\r\n  artifactId: \"jenkins-war\"\r\n  source:\r\n    version: 2.164.3\r\n\r\nplugins:\r\n  #\r\n  # required\r\n  #\r\n  - groupId: \"io.jenkins\"\r\n    artifactId: \"configuration-as-code\"\r\n    source:\r\n      version: \"1.15\"\r\n  - groupId: \"io.jenkins.configuration-as-code\"\r\n    artifactId: \"configuration-as-code-support\"\r\n    source:\r\n      version: \"1.15\"\r\n...\r\n  - groupId: org.jenkins-ci.plugins\r\n    artifactId: plain-credentials\r\n    source:\r\n      version: '1.5'\r\n...\r\n\r\ncasc:\r\n  - id: \"casc\"\r\n    source:\r\n      dir: some-ci.conf.yml\r\n```\r\nCASC:\r\n```\r\ncredentials:\r\n  system:\r\n    domainCredentials:\r\n    - credentials: \r\n      - gitLabApiTokenImpl:\r\n          apiToken: ${jenkins_apikey_gitlab}\r\n          id: jenkins_apikey_gitlab\r\n          scope: GLOBAL\r\n      - file:\r\n          id: cert_devopsjenkinsgke\r\n          filename: k8s.crt\r\n          secretBytes: ${cert_devopsjenkinsgke_b64}\r\n          scope: GLOBAL\r\n...\r\n  clouds:\r\n  - kubernetes:\r\n      credentialsId: ${admin_creds_devopsjenkinsgke}\r\n      serverCertificate: ${cert_devopsjenkinsgke}\r\n\r\n```\r\n\r\nI am using K8S secrets to provide credentials to CASC. It works fine for any field (mentioned some of them in config) except of the file credentials' secretBytes.\r\nHere is what I get in Jenkins startup logs:\r\n```\r\nMay 16, 2019 5:58:07 PM io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator tryConstructor\r\nINFO: Setting class org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl.secretBytes = ${cert_devopsjenkinsgke_b64}\r\nMay 16, 2019 5:58:07 PM jenkins.InitReactorRunner$1 onTaskFailed\r\nSEVERE: Failed ConfigurationAsCode.init\r\njava.lang.Error: java.lang.reflect.InvocationTargetException\r\n        at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)\r\n        at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)\r\n        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)\r\n        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1096)\r\n        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)\r\n        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)\r\n        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\r\n        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\r\n        at java.lang.Thread.run(Thread.java:748)\r\nCaused by: java.lang.reflect.InvocationTargetException\r\n...\r\nCaused by: io.jenkins.plugins.casc.ConfiguratorException: credentials: error configuring 'credentials' with class io.jenkins.plugins.casc.support.credentials.CredentialsRootConfigurator configurator\r\n...\r\nCaused by: io.jenkins.plugins.casc.ConfiguratorException: file: Failed to construct instance of class org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl.\r\n Constructor: public org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl(com.cloudbees.plugins.credentials.CredentialsScope,java.lang.String,java.lang.String,org.apache.commons.fileupload.FileItem,java.lang.String,com.cloudbees.plugins.credentials.SecretBytes) throws java.io.IOException.\r\n Arguments: [com.cloudbees.plugins.credentials.CredentialsScope$2, java.lang.String, null, null, null, com.cloudbees.plugins.credentials.SecretBytes]\r\n        at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149)\r\n...\r\n```\r\nSo it is just not replaced for some reason.\r\nFile representing K8S secret exists in container: \r\n```\r\n$ >>> kubectl -n k8s-jenkins exec -it jenkins-0 cat /secrets/cert_devopsjenkinsgke_b64\r\n{LS0tLS1CRUdJTiBDRVJUSUZ ...\r\n```\r\n\r\nSpent some time investigating it, but with no luck. Could someone help me with that?"},"comment":{"url":"https://api.github.com/repos/jenkinsci/configuration-as-code-plugin/issues/comments/493419187","html_url":"https://github.com/jenkinsci/configuration-as-code-plugin/issues/884#issuecomment-493419187","issue_url":"https://api.github.com/repos/jenkinsci/configuration-as-code-plugin/issues/884","id":493419187,"node_id":"MDEyOklzc3VlQ29tbWVudDQ5MzQxOTE4Nw==","user":{"login":"dev-dsp","id":4235552,"node_id":"MDQ6VXNlcjQyMzU1NTI=","avatar_url":"https://avatars1.githubusercontent.com/u/4235552?v=4","gravatar_id":"","url":"https://api.github.com/users/dev-dsp","html_url":"https://github.com/dev-dsp","followers_url":"https://api.github.com/users/dev-dsp/followers","following_url":"https://api.github.com/users/dev-dsp/following{/other_user}","gists_url":"https://api.github.com/users/dev-dsp/gists{/gist_id}","starred_url":"https://api.github.com/users/dev-dsp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dev-dsp/subscriptions","organizations_url":"https://api.github.com/users/dev-dsp/orgs","repos_url":"https://api.github.com/users/dev-dsp/repos","events_url":"https://api.github.com/users/dev-dsp/events{/privacy}","received_events_url":"https://api.github.com/users/dev-dsp/received_events","type":"User","site_admin":false},"created_at":"2019-05-17T11:21:59Z","updated_at":"2019-05-17T11:21:59Z","author_association":"NONE","body":"Oh I see it now, should be fileName, not filename"}}
{"actor":{"display_login":"dev-dsp"}}