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

[JENKINS-58970] - allow setting engine version on VaultConfiguration #42

Merged
merged 3 commits into from Aug 20, 2019

Conversation

jetersen
Copy link
Member

@jetersen jetersen commented Aug 20, 2019

fixes #40

@jetersen jetersen added the bug label Aug 20, 2019
@jetersen jetersen changed the title Fix default engine version [JENKINS-58970] - allow setting engine version on configuration Aug 20, 2019
@jetersen jetersen changed the title [JENKINS-58970] - allow setting engine version on configuration [JENKINS-58970] - allow setting engine version on VaultConfiguration Aug 20, 2019
@jetersen jetersen merged commit 23d3d3a into jenkinsci:master Aug 20, 2019
@jetersen jetersen deleted the fix/defaultEngineVersion branch August 20, 2019 02:58
@kkalugerov
Copy link

kkalugerov commented Aug 20, 2019

As I can see from you PR the value of the field is engineVersion but where exactly should be this value - in the wrapper like this - >

wrap([$class: 'VaultBuildWrapper', engineVersion: 1/2, vaultSecrets: secrets])

or in the secrets var like this ->

def secrets = [[path: 'secret/test', engineVersion: 1/2,  secretValues: [ envVar: 'test_db', vaultKey: 'test-db']]]

Thanks in advance ! :)

@jetersen
Copy link
Member Author

You can also set it higher up on the configuration object it is under the advanced button

@jetersen
Copy link
Member Author

jetersen commented Aug 20, 2019

Here is an updated groovy snippet instead of using wrap you can use withVault same functionality just shorter to write.
engineVersion can be set from a secret, job, folder or global.

node {
    // define the secrets and the env variables
    def secrets = [
        [path: 'secret/testing', engineVersion: 1, secretValues: [
            [envVar: 'testing', vaultKey: 'value_one'],
            [envVar: 'testing_again', vaultKey: 'value_two']]],
        [path: 'secret/another_test', engineVersion: 2, secretValues: [
            [vaultKey: 'another_test']]]
    ]

    // optional configuration, if you do not provide this the next higher configuration
    // (e.g. folder or global) will be used
    def configuration = [vaultUrl: 'http://my-very-other-vault-url.com',
                         vaultCredentialId: 'my-vault-cred-id'
                         engineVersion: 1]
    // inside this block your credentials will be available as env variables
    withVault([configuration: configuration, vaultSecrets: secrets]) {
        sh 'echo $testing'
        sh 'echo $testing_again'
        sh 'echo $another_test'
    }
}

@kkalugerov
Copy link

Thank you man !

@jetersen
Copy link
Member Author

Your welcome 👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants