hashicorp-vault-plugin icon indicating copy to clipboard operation
hashicorp-vault-plugin copied to clipboard

Token file credential java.io.FileNotFoundException

Open sweeny-here opened this issue 3 years ago • 1 comments

Hi - when running the following pipeline on a worker node, the following exception occurs:

`node {
    def secrets = [
        [path: 'my-path/dev/searches/users/admin', engineVersion: 1, secretValues: [
            [envVar: 'PASSWORD', vaultKey: 'admin.password']]
        ]
    ]

    def configuration = [vaultUrl: 'https://my-vault.com:8200/',
                         vaultCredentialId: 'vault',
                         engineVersion: 1]

    withVault([configuration: configuration, vaultSecrets: secrets]) {
        sh 'echo $PASSWORD'
    }
}`
`java.io.FileNotFoundException: File '/home/ec2-user/.vault-token' does not exist
	at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:297)
	at org.apache.commons.io.FileUtils.readFileToS`

The "vault" token file credential has been created and exists, yet the withVault plugin can't source it.

Any ideas?

sweeny-here avatar Nov 27 '20 17:11 sweeny-here

Jenkins agent or server does not have permission to write to /home/ec2-user/

Please ensure you create a separate user for Jenkins to have full permission to it's home folder. You shouldn't give Jenkins access to write to ec2-user

jetersen avatar Nov 27 '20 18:11 jetersen