Package com.datapipe.jenkins.vault
Class VaultCredentialsStep
java.lang.Object
hudson.model.AbstractDescribableImpl<org.jenkinsci.plugins.workflow.steps.Step>
org.jenkinsci.plugins.workflow.steps.Step
com.datapipe.jenkins.vault.VaultCredentialsStep
- All Implemented Interfaces:
ExtensionPoint,Describable<org.jenkinsci.plugins.workflow.steps.Step>
public class VaultCredentialsStep
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 path parameter combines the KV path and field name: the last segment after the
final / is used as the field key, and everything before it is the secret path.
environment {
DB_HOST = vaultCredentials(path: 'secret/myapp/db/host', credentialsId: 'vault-approle')
DB_PASS = vaultCredentials(path: 'secret/myapp/db/password', credentialsId: 'vault-approle',
vaultUrl: 'https://vault:8200', vaultNamespace: 'prod')
}
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) getPath()booleanvoidsetMaskSecret(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
-
VaultCredentialsStep
-
-
Method Details
-
setVaultUrl
-
setVaultNamespace
-
setMaskSecret
@DataBoundSetter public void setMaskSecret(boolean maskSecret) -
getPath
-
getCredentialsId
-
getVaultUrl
-
getVaultNamespace
-
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
-