tip
Secrets from 1Password env for Gradle
TL;DR Gradle cannot read .env files, so signing secrets end up in a plaintext gradle.properties. A 1Password Environment can mount a named pipe instead of a file, and a small class in your build logic can read that pipe, so no plaintext secret file exists on disk.
My ~/.gradle/gradle.properties held several signing secrets in plaintext. The 1Password mount that replaces them shows up as prw-------: type p, a named pipe, size 0.
Gradle has no .env support
The options for getting dotted property names like android.signing.* out of a secret manager:
ORG_GRADLE_PROJECT_*variables work for plain names like Maven Central or GPG keys. Shells do not allow dots in variable names, so they cannot carry the signing properties.An
op runwrapper works from a terminal. I do not want to start every build through it.An init script in
~/.gradle/init.dread the pipe fine. A failed read, though, got stored in the configuration cache and the next run silently reused it: "Configuration cache entry stored." with no secrets, then "Reusing configuration cache.". It is also machine-global.
I skipped external dotenv plugins. Claude Code wrote the code and ran the tests; the decisions are mine.
From 1Password to the signing config
Mounts the Environment as a file path and serves values on read.
Nothing is stored; each read is answered on demand.
A short-lived cat <path> with a 60 second timeout.
Parses the KEY=VALUE lines. Cached per project, reads are serialized.
The Android signing block takes store file, passwords and alias.
Gradle rejects pipes, so the plugin reads through cat
In the 1Password app, enable the Local .env file destination of the Environment. Then check the type:
$ ls -la ~/.config/op/env/ prw-------@ 1 mikepenz staff 0 Dec 4 08:06 opensource-android-signing.env
Mode 600, size 0. The first read asks 1Password for approval: 1.91s and 1.69s on two mounts, from a quick Python reader. The second read took 0.20s without a prompt. 1Password documents that the approval lasts until 1Password locks.
Gradle's tracked file APIs refuse a pipe:
The env file '~/.config/op/env/opensource-android-signing.env' could not be read: Unsupported file type for ...So the plugin spawns cat inside an EnvFileValueSource. A ValueSource is revalidated on every build, so the pipe is read every build, and runs 2 and 3 printed "Reusing configuration cache." with signing applied. 1Password says its mounts are not built for concurrent readers, hence one JVM-wide lock around the read.
The env file is the last fallback
The signing block resolves each value in this order, first hit wins:
Order | Source |
|---|---|
1 | Gradle property ( |
2 | Env var |
3 | Env file from |
Keys inside the file are ANDROID_SIGNING_<VARIANT>_{STORE_FILE,STORE_PASSWORD,KEY_ALIAS,KEY_PASSWORD}. Old values in ~/.gradle/gradle.properties win over the file, so they hide whether the mount works.
Prove the pipe is the only source
Decide whether you trust it: blank every old source for one run, then see if signing still resolves.
Step 1 of 4
Enable the mount
Create the local .env destination for the Environment and note its path.
Point the build at it
Set env.files in local.properties to that path.
Blank the old values
Pass each old property as an empty -P override, for example -P<old.property>=, and unset any ANDROID_SIGNING_* variables in your shell.
Run signingReport
./gradlew signingReport still lists the keystore and alias. With every other source blank, they can only have come from the pipe.
Try it yourself
In local.properties, with your own variant and path. The full property names start with com.mikepenz., which the text above leaves out:
com.mikepenz.android.signing.enabled=true
com.mikepenz.android.signing.variant=openSource
com.mikepenz.env.files=~/.config/op/env/opensource-android-signing.envThis is in convention 0.14.1 (PR #56). By design, CI is unchanged unless env.files or ANDROID_SIGNING_* variables are set, and -P and ORG_GRADLE_PROJECT_* still win. A missing env file only warns.
Honest limits
macOS and Linux only: 1Password documents local .env mounts for those, and
catmakes the reader Unix-only.The 1Password app must be running, and every first read needs its approval.
Gradle writes the resolved values into the configuration cache entry. It encrypts that entry, but it is on disk.
The
.jkskeystore stays on disk, protected by its password, unless you store it base64-encoded asstoreBase64. The build then decodes it tobuild/signing/<variant>.keystoreand deletes it when the build ends.An env file that exists but cannot be read within 60 seconds fails the build on purpose.
Blank the old entries in ~/.gradle/gradle.properties before you test, or you are testing the old file.