0

是否可以获得在多分支管道项目中配置的 git scm 插件的 credentialIds?

node {
    def app

    stage('clone') {
        checkout scm // has credentials defined in project settings
    }

    environment {
        GIT_CREDENTIALS = credentials(GitSCM.Plugin.CredentialsId) // possible?
    }

    stage('build') {
        git config --global credential.username ${GIT_CREDENTIALS_USR}
        git config --global credential.helper "!echo password=${GIT_CREDENTIALS_PSW}; echo"
        sh "npm ci" // has private git repo dependency
    }
}

节点项目在其 package.json 中具有对私有存储库的依赖项,我想重用凭据而不配置它们两次。

4

0 回答 0