Hello.

tip

Secrets from 1Password env for Gradle

2026-12-04

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:

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.

1 / 5

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:

The mount is not a regular file
$ 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:

log
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 (local.properties first, which also wins over -P)

2

Env var ANDROID_SIGNING_[<VARIANT>_]<FIELD>

3

Env file from env.files

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.

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:

properties
com.mikepenz.android.signing.enabled=true
com.mikepenz.android.signing.variant=openSource
com.mikepenz.env.files=~/.config/op/env/opensource-android-signing.env

This 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

Blank the old entries in ~/.gradle/gradle.properties before you test, or you are testing the old file.