Travis CI fork pull request builds cannot access encrypted environment variables
0 reputation · 04 Jun 2026, 02:39 UTC
0 reputation · 04 Jun 2026, 02:39 UTC
On the current travis-ci.com platform, builds for pull requests opened from forks of a public repository do not receive the encrypted environment variables defined in .travis.yml (secure: entries) or in repository settings. The isolation is deliberate: build logs for public repositories are public, and Travis CI withholds secrets from builds whose scripts an outside contributor can modify.
The difficulty is the all-or-nothing model. Fork PR builds may legitimately need credentials for integration tests, yet there appears to be no per-contributor, per-variable, or per-PR mechanism to expose specific secrets to a trusted fork build. The “Build fork pull requests” setting only controls whether such builds trigger, and variables created with travis encrypt appear to follow the same restriction as those added through the settings UI.
secure: variables and settings-defined variables on the current platform?30275 reputation · 04 Jun 2026, 10:17 UTC
1. Does Travis CI offer a supported way to grant encrypted variables to a selected fork PR or trusted contributor?
No. The platform‑wide security policy on travis-ci.com explicitly removes all encrypted environment variables—both secure: entries in .travis.yml and variables added via the repository settings—from the environment of any pull‑request build that originates from a fork. There is no per‑variable, per‑contributor, or per‑PR exception.
2. Which documented configuration keeps fork PR builds useful while preserving secret isolation?
if: fork = false or if: type != pull_request so they run only on trusted commits (e.g., merges to protected branches).3. Is the restriction identical for secure: variables and settings‑defined variables?
Yes. Both types are encrypted at rest and are excluded from fork PR build environments.
Travis CI’s security model treats any build that can run arbitrary code from an untrusted contributor as a potential attack vector. By withholding encrypted secrets, the platform ensures that the logs of a public repository remain public and that external contributors cannot exfiltrate sensitive data. The "Build fork pull requests" toggle only controls whether the build is triggered; it does not influence secret injection.
secure: entries and repository‑settings variables..travis.yml and repository settings. Separate public from private vars. Example: env:
global:
- MY_PUBLIC_VAR=foo
matrix:
- secure: # This will be stripped from fork PR builds
before_install:
- pip install awscli
- export MY_SECRET=$(aws secretsmanager get-secret-value \
--secret-id my-secret-id \
--query SecretString --output text)
.travis.yml:
jobs:
include:
- stage: integration
if: fork = false
script: run-integration-tests.sh
Do you need the secrets for integration tests that run on the fork PR itself, or can you move those tests to run only after the PR is merged into a protected branch?
| Component | Behavior |
|---|---|
| Fork PR Build | No Encrypted Vars |
| Public Vars | Passed Through |
| External Secret Store | Fetched at Runtime |
| Job Gating | Run Only on Trusted Builds |
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.