Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use vaultCredential with in the configuration block in Jenkins? #280

Open
Thilaknath opened this issue Jan 17, 2023 · 1 comment
Open

Comments

@Thilaknath
Copy link

Thilaknath commented Jan 17, 2023

Is my below configuration correct? I would like to use the withVault block with vaultCredential instead of the vaultCredentialID, I am not sure how to pass the secretID, As if I pass a credential ID of a stored secretText present in jenkins, It complains of the following error

java.lang.ClassCastException: com.datapipe.jenkins.vault.credentials.VaultAppRoleCredential.secretId expects class hudson.util.Secret but received class java.lang.String

withVault(configuration: [
        timeout: 60,
        vaultCredential: [
                $class: 'VaultAppRoleCredential',
                scope: 'GLOBAL',
                roleId: '********',
                secretId: 'REPLACE-ME'
        ],
        vaultNamespace: 'our vault namespace',
        vaultUrl: 'our vault path'
],
          vaultSecrets: [
                  [
                          path: 'piper/PIPELINE-GROUP-779/GROUP-SECRETS/company',
                          secretValues: [
                                  [envVar: 'MY_COMPANY_NAME', vaultKey: 'team']
                          ]
                  ]
          ]) {
    script {
        sh "echo $MY_COMPANY_NAME"

        print 'MY_COMPANY_NAME.collect { it }=' + MY_COMPANY_NAME.collect { it }
    }
}
@Jason-Lam-1
Copy link

secretId: 'REPLACE-ME' should be secretId: Secret.fromString('REPLACE-ME')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants