简体   繁体   中英

Beyond the normal: How to set git credentials using credentials parameter

The documentation says:

// use the github-ci-key credentials for authentication with GitHub
job('example-1') {
    scm {
        git {
            remote {
                github('account/repo', 'ssh')
                credentials('github-ci-key')
            }
        }
    }
}

Which is lovely...but...

We are building our script up:

scm {
  git {
    remote {
      url(githubUrl) <--Predefined
      credentials('jenkins6'/'ci-key')
    }
  }
}

And it isn't working.

Why the non-standard Jenkins name? Because we are only one project and they need to make sure that the Jenkins user(s) are segregated (yeah, you know...)

Practically what we want to do (and can do from the UI) is set the Jenkins username (to Jenkins6) and then pull the key from the Jenkins master ~/.ssh, but HOW do we do that in the jobdsl? The documentation is less than clear - you would think no one had ever asked for that scenario, yet I suspect many are doing it, so what is the trick?

From the TMTOWTDI camp...we are going to modify the ~/.ssh/config and add the second special user and host.

I would love to know if there was a way to do it with the the jobdsl.groovy option too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM