You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+184-32
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
This plugin adds a build wrapper to set environment variables from a HashiCorp [Vault](https://www.vaultproject.io/) secret. Secrets are generally masked in the build log, so you can't accidentally print them.
5
5
It also has the ability to inject Vault credentials into a build pipeline or freestyle job for fine-grained vault interactions.
6
6
7
-
# Vault Authentication Backends
7
+
##Vault Authentication Backends
8
8
This plugin allows authenticating against Vault using the AppRole authentication backend. Hashicorp recommends using AppRole for Servers / automated workflows (like Jenkins) and using Tokens (default mechanism, Github Token, ...) for every developer's machine.
9
9
Furthermore, this plugin allows using a Github personal access token, or a Vault Token - either configured directly in Jenkins or read from an arbitrary file on the Jenkins Machine.
10
10
@@ -28,7 +28,7 @@ The `Descriptor` needs to be annotated with `@Extension`. Your credential needs
28
28
See [VaultAppRoleCredential.java](https://github.com/jenkinsci/hashicorp-vault-plugin/blob/master/src/main/java/com/datapipe/jenkins/vault/credentials/VaultAppRoleCredential.java) for an example.
29
29
30
30
31
-
# Plugin Usage
31
+
##Plugin Usage
32
32
### Configuration
33
33
You can configure the plugin on three different levels:
34
34
* Global: in your global config
@@ -105,7 +105,7 @@ node {
105
105
// optional configuration, if you do not provide this the next higher configuration
There is an easier way to setup the global Vault configuration on your Jenkins server.
142
+
No need for messing around in the UI.
140
143
141
-
# Migration Guide
142
-
143
-
### Upgrade from 1.x to 2.0
144
-
The `BuildWrapper` did not change, so no changes to your Jenkinsfile should be necessary. However, you need to reconfigure Vault in your Jenkins instance based on the instructions above. There is no way to smoothly upgrade this, because this is a major rewrite and handling of configuration completly changed.
145
-
146
-
# CHANGELOG
147
-
***2018/08/22** - Feature Release - 2.2.0
148
-
* Add support for GCP authentication
149
-
***2018/05/01** - Bugfix Release - 2.1.1
150
-
* MaskingConsoleLogFilter should filter out null secrets [JENKINS-46792](https://issues.jenkins-ci.org/browse/JENKINS-38647)
* Support reading Vault Token from file on disk [JENKINS-37713](issues.jenkins-ci.org/browse/JENKINS-37713)
162
-
* Using credentials plugin for authentication token [JENKINS-38646](issues.jenkins-ci.org/browse/JENKINS-38646)
163
-
***2017/03/03** - Feature Release - 1.3
164
-
* Vault Plugin should mask credentials in build log [JENKINS-39383](issues.jenkins-ci.org/browse/JENKINS-39383)
165
-
***2016/08/15** - Re-release due to failed maven release - 1.2
166
-
***2016/08/11** - Bugfix release - 1.1
167
-
* Refactor to allow getting multiple vault keys in a single API call [JENKINS-37151](https://issues.jenkins-ci.org/browse/JENKINS-37151)
168
-
***2016/08/02** - Initial release - 1.0
144
+
Jenkins Configuration as Code often shorten to [JCasC] or simplify [Configuration as Code plugin]
145
+
allows you to configure Jenkins via a yaml file. If you are a first time user, you can learn more about [JCasC]:point_left:
146
+
147
+
Hashicorp Plugin also adds an extension to [JCasC] by providing a Secret Source for [Configuration as Code plugin] to read secrets from, which you can [read about here](#hashicorp-vault-plugin-as-a-secret-source-for-jcasc)
148
+
149
+
### Prerequisite:
150
+
151
+
Install `Configuration as Code` Plugin on your Jenkins instance.
152
+
153
+
Refer to [Installing a new plugin in Jenkins](https://jenkins.io/doc/book/managing/plugins/#installing-a-plugin).
154
+
155
+
#### Add configuration YAML:
156
+
157
+
There are multiple ways to load JCasC yaml file to configure Jenkins:
158
+
159
+
* JCasC by default searches for a file with the name `jenkins.yaml` in `$JENKINS_ROOT`.
160
+
161
+
* The JCasC looks for an environment variable `CASC_JENKINS_CONFIG` which contains the path for the configuration `yaml` file.
162
+
163
+
* A path to a folder containing a set of config files e.g. `/var/jenkins_home/casc_configs`.
164
+
165
+
* A full path to a single file e.g. `/var/jenkins_home/casc_configs/jenkins.yaml`.
166
+
167
+
* A URL pointing to a file served on the web e.g. `https://<your-domain>/jenkins.yaml`.
168
+
169
+
* You can also set the configuration yaml path in the UI. Go to `<your-jenkins-domain>/configuration-as-code`. Enter path or URL to `jenkins.yaml` and select `Apply New Configuration`.
170
+
171
+
To configure your Vault in Jenkins add the following to `jenkins.yaml`:
See [handling secrets section](https://github.com/jenkinsci/configuration-as-code-plugin#handling-secrets) in JCasC documentation for better security.
192
+
193
+
You can also configure `VaultGithubTokenCredential`, or `VautGCPCredential` or `VaultAppRoleCredential`
194
+
195
+
If you are unsure about how to do it from `yaml`. You can still use the UI to configure credentials.
196
+
After you configured Credentials and the Global Vault configuration.
197
+
you can use the export feature build into JCasC by visiting `<your-jenkins-domain>/configuration-as-code/viewExport`
198
+
199
+
### HashiCorp Vault Plugin as a Secret Source for JCasC
200
+
201
+
We can provide these initial secrets for JCasC
202
+
The secret source for JCasC is configured via environment variables as way to get access to vault at startup and when configuring Jenkins instance.
203
+
204
+
[For Security and compatibility considerations please read more here](https://github.com/jenkinsci/configuration-as-code-plugin#security-and-compatibility-considerations)
205
+
206
+
- The environment variable `CASC_VAULT_PW` must be present, if token is not used and appRole/Secret is not used. (Vault password.)
207
+
- The environment variable `CASC_VAULT_USER` must be present, if token is not used and appRole/Secret is not used. (Vault username.)
208
+
- The environment variable `CASC_VAULT_APPROLE` must be present, if token is not used and U/P not used. (Vault AppRole ID.)
209
+
- The environment variable `CASC_VAULT_APPROLE_SECRET` must be present, it token is not used and U/P not used. (Vault AppRole Secret ID.)
210
+
- The environment variable `CASC_VAULT_TOKEN` must be present, if U/P is not used. (Vault token.)
211
+
- The environment variable `CASC_VAULT_PATHS` must be present. (Comma separated vault key paths. For example, `secret/jenkins,secret/admin`.)
212
+
- The environment variable `CASC_VAULT_URL` must be present. (Vault url, including port number.)
213
+
- The environment variable `CASC_VAULT_AGENT_ADDR` is optional. It takes precedence over `CASC_VAULT_URL` and is used for connecting to a Vault Agent. [See this section](#vault-agent)
214
+
- The environment variable `CASC_VAULT_MOUNT` is optional. (Vault auth mount. For example, `ldap` or another username & password authentication type, defaults to `userpass`.)
215
+
- The environment variable `CASC_VAULT_NAMESPACE` is optional. If used, sets the Vault namespace for Enterprise Vaults.
216
+
- The environment variable `CASC_VAULT_FILE` is optional, provides a way for the other variables to be read from a file instead of environment variables.
217
+
- The environment variable `CASC_VAULT_ENGINE_VERSION` is optional. If unset, your vault path is assumed to be using kv version 2. If your vault path uses engine version 1, set this variable to `1`.
218
+
- The issued token should have read access to vault path `auth/token/lookup-self` in order to determine its expiration time. JCasC will re-issue a token if its expiration is reached (except for `CASC_VAULT_TOKEN`).
219
+
220
+
If the environment variables `CASC_VAULT_URL` and `CASC_VAULT_PATHS` are present, JCasC will try to gather initial secrets from Vault. However for it to work properly there is a need for authentication by either the combination of `CASC_VAULT_USER` and `CASC_VAULT_PW`, a `CASC_VAULT_TOKEN`, or the combination of `CASC_VAULT_APPROLE` and `CASC_VAULT_APPROLE_SECRET`. The authenticated user must have at least read access.
221
+
222
+
You can also provide a `CASC_VAULT_FILE` environment variable where you load the secrets from a file.
0 commit comments