Jenkins Kube 代理无法从 git 中提取



我在 Kubernetes (EKS( 中运行 Jenkins,并且在使用管道代码在 Jenkins master 上运行作业时可以成功拉取 git 存储库

gitInfo = checkout([$class: 'GitSCM',
                branches: [[name: '*/master']],
                doGenerateSubmoduleConfigurations: false,
                extensions: [[$class: 'CleanCheckout'], [$class: 'RelativeTargetDirectory', relativeTargetDir: 'config']],
                submoduleCfg: [],
                userRemoteConfigs: [[credentialsId: 'Gitlab', url: 'git@gitlab.test.com:USER/config.git']]
            ])

它检查得很好。但是,当我尝试拉上 Jenkins kube 代理时,它似乎无法正确从主服务器获取密钥。使用完全相同的结帐代码,我收到错误

using credential Gitlab
Cloning the remote Git repository
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress git@gitlab.test.com:USER/config.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: Warning: Permanently added 'gitlab.test.com,11.11.111.11' (ECDSA) to the list of known hosts.
  Authorized uses only. All activity may be monitored and reported.
  Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
  fatal: Could not read from remote repository.

在工作日志中,我希望看到它尝试使用的凭据的名称

using GIT_SSH to set credentials Git Lab key used to bootstrap Jenkins Master

以前有人见过这个问题吗?

我的容器规格是

spec:
containers:
- name: jnlp
  image: jenkins/jnlp-slave
  imagePullPolicy: Always
  env:
  - name: POD_IP
    valueFrom:
      fieldRef:
        fieldPath: status.podIP
  - name: DOCKER_HOST
    value: tcp://localhost:2375

更新:因此,似乎有什么东西正在从凭据存储中id_rsa密钥的末尾剥离换行符。我正在使用 Jenkins Config 即代码从 AWS 参数存储中添加它,所以我认为这里出了点问题,就好像我从参数存储中转储密钥的内容并通过 Jenkins UI 将其复制并粘贴到凭据中作业工作......

问题是由 JCasC 无法从 AWS 获取参数引起的,因此 Jenkins 凭证已损坏(空白(。

通过在凭据上运行 cat 并在脚本控制台中解密凭据.xml进行调试

println(hudson.util.Secret.decrypt("{XXXXXXXX}"))

我不知道主服务器如何使用空白凭据从 Git 克隆,但即使在 UI 中它也显示为有效:/

最新更新