Use HashiCorp Vault secret to autenticate GitHub in jenkins pipeline

Viewed 79

I am trying to aunthenticate GitHub repository, wth the token I retrieve from HashiCorp Vault. Git plugin supports only the parameter credentialsId, which takes credentials stored in Jenkins (username and password). Is there a way, how to autenticate with the variable, which contains token?

jenkins pipeline code:

node {

    def secrets = [
        [path: 'ddci/test', engineVersion: 2, secretValues: [
            [envVar: 'token', vaultKey: 'heslo']
      ]]     
    ]
 
    def configuration = [vaultUrl: 'https://vault.tools.sap/',
                         vaultCredentialId: 'hashicorp_vault',
                         engineVersion: 2]
  
  
    stage('use token to authenticate GITHub') { 
      withVault([configuration: configuration, vaultSecrets: secrets]) {
        git credentialsId: '$heslo', url: 'https://github.tools.sap/AZURE-PIPELINES-SYSDEV/decdev-ci-verification', branch: 'master'
    }
    }
  
}
0 Answers
Related