CodeQL "No source code was seen during the build" in CI
For compiled languages CodeQL only records files it observes being compiled. If your build step did nothing, used a cache, or skipped compilation, the extractor sees no source and the analysis has nothing to scan.
What this error means
The analyze step fails with "No source code was seen during the build for ..." or "CodeQL did not detect any code written in languages supported by CodeQL". The build itself may have "succeeded".
Error: No source code was seen during the build for the following languages: java.
Please review our troubleshooting guide at https://docs.github.com/code-security ...
CodeQL did not detect any code written in languages supported by CodeQL.Common causes
The build was a no-op or fully cached
An incremental or cached build recompiled nothing, so the extractor observed no compiler calls and captured no source.
Autobuild ran but did not compile your code
Autobuild built a wrapper, a subproject, or nothing at all, missing the module that holds the real source.
How to fix it
Force a clean, full compile
- Disable build caches or incremental builds for the CodeQL job.
- Run a clean build that compiles every source file CodeQL should see.
- Confirm the analyze step follows the build in the same job.
- uses: github/codeql-action/init@v3
with:
languages: java
build-mode: manual
- run: mvn -B -Dmaven.test.skip=true clean compile
- uses: github/codeql-action/analyze@v3Point the build at the right directory
In a monorepo, run the build from the module that contains the code to scan so the extractor observes those compilations.
- run: |
cd services/api
./gradlew --no-build-cache clean compileJavaHow to prevent it
- Always run a clean full compile in the CodeQL job for compiled languages.
- Disable incremental/cached builds so every file is observed.
- Verify the analyze step runs in the same job as the build.