在管道执行期间,Jenkins Kubernetes 插件没有将 credentials/secrets 从 master 拉到 PodTemplate/ContainerTemplate?

No credentials/secrets pulled from master into PodTemplate/ContainerTemplate by Jenkins Kubernetes Plugin during pipeline execution?

布景: 我设置了多节点Kubernetes cluster and deployed the Jenkins Helm Chart with the Jenkins Kubernetes plugin. We run (company-)internally an Enterprise GitHub installation and we have multiple private and public repos. The builds are implemented using non-declarative Jenkins pipelines (many features are missing in the plugin for declarative pipelines). The builds don't run on the Jenkins master, but every job run consumes its own pod for obvious reasons (maximum scale-out and total isolation/no side effects) via podTemplates/containerTemplates.

problem/question: 我没有找到任何方法或描述如何从私人回购中获取,或者更一般地说,我没有找到任何方法从 Jenkins master(我喜欢集中维护它们)中提取任何 credentials/secrets 到 pods/containers该插件为我的工作创建 运行s,即我想念那些 pods/containers 例如credentials/secrets 从私人仓库中提取。我怎样才能使那些在动态产生的 pods/containers 中可用?这可能吗?

一些附加信息: 在我的 Jenkins master 上,我可以完美地从私人仓库中获取,可以访问所有内容,一切都很好。直到最近我才尝试使用 Kubernetes 插件并从我的集群中获得更多。此外,我 kubectl exec 进入了 JNLP 从属容器(及其基于我的 containerTemplates 的同级容器),但找不到任何东西。不在 ENV 中,不在文件中。我不清楚我的 credentials/secrets 将如何被注入,以及我需要为此做些什么。

我已经使用过的脏解决方案,但我想替换: 为了解决这个问题,我将我的凭据放入 JenkinsFile,但这很糟糕,因为我现在将它们涂抹在我的回购协议上,而且它也不是 public 回购协议的解决方案。我还做的是将它们烘焙到我的 pod/container 模板图像中,但出于与我现在将它们放入 DockerFiles(在构建期间直接或间接)并且不能使用现成的类似原因,这很丑陋不再搁置图像,也不能再将我的图像放入 public 图像存储库中。我想也可以修改我的最顶层 podTemplate/containerTemplate 并使用 credentials/secrets 手动添加 ENV 变量,但这很丑陋,而且我不会使用 Jenkins master credentials/secrets 存储更多。

我正在寻找问题的干净解决方案。我希望,可以将我的 credentials/secrets 从 Jenkins master 带到我动态生成的 pods/containers 中,我也想保留它(没有静态奴隶,但每个工作都有动态奴隶 运行 ).

git url: 'private-gitlab-address',
    branch: 'master',
    credentialsId : 'my_jenkins_credential_id'

您可以通过此页面创建自己的 my_jenkins_credential_id 全球可用:

jenkins-master-address/credentials/store/system/domain/_/newCredentials