jenkinsci / onepassword-secrets-plugin

https://plugins.jenkins.io/onepassword-secrets/
MIT License
5 stars 3 forks source link

Loading from .env? #12

Open rsov opened 5 months ago

rsov commented 5 months ago

What feature do you want to see added?

Make it possible to load the secrets from .env file inside Jenkins pipeline

Currently if you have .env with secret refs you'd need to duplicate it in the Jenkins pipeline.

Ex .env:

DB_PASS=op://prod/db/password

Jenkinsfile

def secrets = [
    [envVar: 'DB_PASS', secretRef: 'op://prod/db/password'], // DUPLICATION
]
pipeline {
    agent any
    stages{
        stage('Build') {
            steps {
                withSecrets(config: config, secrets: secrets) {
                      sh './bin/run $DB_PASS'
                }
            }
        }
    }
}

Proposed Jenkinsfile

pipeline {
    agent any
    stages{
        stage('Build') {
            steps {
                withSecrets(config: config, envFile: '.env') { // PASS THE PATH
                      sh './bin/run $DB_PASS'
                }
            }
        }
    }
}

This will work very similarly as op run --env-file="./.env" command

Upstream changes

No response

Are you interested in contributing this feature?

No response

mihaiplesa commented 1 month ago

This would be very useful.