Jenkins - Git Submodule Credentials Different from Parent Repo

前端 未结 1 1428
庸人自扰
庸人自扰 2021-02-13 11:12

Background

Jenkins is being used to build an artifact from a Git repo that has a Git submodule. The submodule(s) are not in the same repo or even at the same endpoint a

1条回答
  •  执念已碎
    2021-02-13 11:58

    Yes this is easily done. You can create pub/private key pair and set it up as a github deploy key (if you are using git hub if not, then as a key set in whatever you do use). You can add that as a Jenkins credential (provided you have the credentials plugin installed).

    Username: git@github.com
    Private Key:  the private key for that key set
    Passphrase:  whatever passphrase you used
    ID: aws-jenkins-github-deploykey (just an example name)
    Description: some useful text
    

    The ID maps to the credentialsId below

    checkout changelog: true, poll: false, scm: [$class: 'GitSCM',
         branches: [[name: "branch name, commit sha, or tag/tagname" ]],
         userRemoteConfigs: [[
         credentialsId: 'aws-jenkins-github-deploykey',
         url: 'git@github.com:myorg/myrepo.git']]]
    

    When this Pipeline code runs, it checks out the repo at the branch, commit, etc to the working directory. You can also specify the directory.

    So you can use this to checkout a bunch of repos and use specific branches for them.

    0 讨论(0)
提交回复
热议问题