Package com.mwdle.bitwarden.cli
Class BitwardenCli
java.lang.Object
com.mwdle.bitwarden.cli.BitwardenCli
A utility for executing Bitwarden CLI commands.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidconfigServer(String serverUrl) Configures the Bitwarden server URL.static BitwardenItemReturns a single Bitwarden item from the vault.static List<BitwardenItemMetadata> listItemsMetadata(Secret sessionKey) Returns a list of all Bitwarden item metadata from the vault.static voidlogin(com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials apiKey) Logs into the vault.static voidlogout()Logs out of the Bitwarden CLI.static voidSynchronizes the vault with the Bitwarden server.static Secretunlock(org.jenkinsci.plugins.plaincredentials.StringCredentials masterPassword) Unlocks the vault and returns the session key.static Stringversion()
-
Method Details
-
version
- Returns:
- the version of the installed Bitwarden CLI
- Throws:
InterruptedException- if the command is interruptedIOException- if the command fails
-
configServer
Configures the Bitwarden server URL.- Parameters:
serverUrl- the URL of the Bitwarden server- Throws:
InterruptedException- if the command is interruptedIOException- if the command fails
-
login
public static void login(@NonNull com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials apiKey) throws InterruptedException, IOException Logs into the vault.- Parameters:
apiKey- the Jenkins credential containing the Bitwarden API key- Throws:
InterruptedException- if the command is interruptedIOException- if the command fails
-
unlock
@NonNull public static Secret unlock(@NonNull org.jenkinsci.plugins.plaincredentials.StringCredentials masterPassword) throws InterruptedException, IOException Unlocks the vault and returns the session key.- Parameters:
masterPassword- the Jenkins credential containing the Bitwarden master password- Returns:
- an active session key
- Throws:
InterruptedException- if the command is interruptedIOException- if the command fails
-
sync
Synchronizes the vault with the Bitwarden server.- Parameters:
sessionKey- an active session key- Throws:
InterruptedException- if the command is interruptedIOException- if the command fails
-
listItemsMetadata
@NonNull public static List<BitwardenItemMetadata> listItemsMetadata(@NonNull Secret sessionKey) throws InterruptedException, IOException Returns a list of all Bitwarden item metadata from the vault.- Parameters:
sessionKey- an active session key- Returns:
- a list of Bitwarden item metadata
- Throws:
InterruptedException- if the command is interruptedIOException- if the command or JSON parsing fails
-
getItem
@NonNull public static BitwardenItem getItem(@NonNull Secret sessionKey, @NonNull String itemId) throws InterruptedException, IOException Returns a single Bitwarden item from the vault.- Parameters:
sessionKey- an active session keyitemId- the UUID of the Bitwarden item to fetch- Returns:
- a Bitwarden item
- Throws:
InterruptedException- if the command is interruptedIOException- if the command or JSON parsing fails
-
logout
Logs out of the Bitwarden CLI.- Throws:
InterruptedException- if the command is interruptedIOException- if the CLI executable path cannot be determined
-