Skip to content

Loading from .env? #12

@rsov

Description

@rsov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions