Package com.datapipe.jenkins.vault
Class VaultStep
java.lang.Object
hudson.model.AbstractDescribableImpl<org.jenkinsci.plugins.workflow.steps.Step>
org.jenkinsci.plugins.workflow.steps.Step
com.datapipe.jenkins.vault.VaultStep
- All Implemented Interfaces:
ExtensionPoint,Describable<org.jenkinsci.plugins.workflow.steps.Step>
public class VaultStep
extends org.jenkinsci.plugins.workflow.steps.Step
Pipeline step that fetches a single value from a Vault KV secret and returns it as a String.
Designed for use inside Declarative Pipeline
environment {} blocks.
The field to read can be given two ways:
- explicitly via the
keyparameter (in which casepathis used verbatim), or - folded into
path, where the last segment after the final/is the field key and everything before it is the secret path. This applies only whenkeyis absent.
environment {
// explicit key (drop-in compatible with the hashicorp-vault-pipeline-plugin `vault` step)
DB_USER = vault path: 'secret/myapp/db', key: 'username', engineVersion: '2'
// key folded into path
DB_HOST = vault(path: 'secret/myapp/db/host', credentialsId: 'vault-approle')
DB_PASS = vault(path: 'secret/myapp/db/password', credentialsId: 'vault-approle',
vaultUrl: 'https://vault:8200', vaultNamespace: 'prod')
}
Breaking change: this step is registered under the function name vault. It
supersedes the vaultCredentials step name shipped in release 381.v4277b_9fa_a_380
(#367); that name is no longer registered. Pipelines that adopted vaultCredentials(...)
must switch to vault(...). Aligning on the vault name is what makes migrating off
the abandoned hashicorp-vault-pipeline-plugin a drop-in (see #369).
When credentialsId is omitted the global Vault configuration's credential is used.
When maskSecret is true (the default), the resolved value is registered with
VaultMaskedValuesFilter so it is automatically redacted from subsequent console output.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringfetchValue(String path, String key, Run<?, ?> run, TaskListener listener) getKey()getPath()booleanvoidsetCredentialsId(String credentialsId) voidsetEngineVersion(String engineVersion) Per-call KV engine version override.voidvoidsetMaskSecret(boolean maskSecret) voidsetVaultNamespace(String vaultNamespace) voidsetVaultUrl(String vaultUrl) org.jenkinsci.plugins.workflow.steps.StepExecutionstart(org.jenkinsci.plugins.workflow.steps.StepContext context) Methods inherited from class org.jenkinsci.plugins.workflow.steps.Step
getDescriptor
-
Constructor Details
-
VaultStep
-
-
Method Details
-
setKey
-
setCredentialsId
-
setVaultUrl
-
setVaultNamespace
-
setEngineVersion
Per-call KV engine version override. Declared as a String (e.g.'1'or'2') to match the oldvault path: '...', engineVersion: '2'syntax exactly, so existing pipelines bind as-is. Quote the value, as the old step required. -
setMaskSecret
@DataBoundSetter public void setMaskSecret(boolean maskSecret) -
getPath
-
getKey
-
getCredentialsId
-
getVaultUrl
-
getVaultNamespace
-
getEngineVersion
-
isMaskSecret
public boolean isMaskSecret() -
start
public org.jenkinsci.plugins.workflow.steps.StepExecution start(org.jenkinsci.plugins.workflow.steps.StepContext context) throws Exception - Specified by:
startin classorg.jenkinsci.plugins.workflow.steps.Step- Throws:
Exception
-
fetchValue
-