CodeQL "Autobuild failed" for a compiled language in CI
Autobuild tried to compile your project so CodeQL could extract a database, and the build command it chose failed. The real error (a missing JDK, wrong SDK, or unresolved dependency) is in the autobuild output above the summary.
What this error means
The "Autobuild" step ends with "Autobuild failed" and a build tool error above it. It affects compiled languages (Java, C#, C/C++, Go, Swift) where CodeQL must build to extract.
[build-status] Attempting to automatically detect build system...
[build] ERROR: Could not resolve dependencies for project com.example:app:jar
Autobuild failed: We were unable to automatically build your code.Common causes
Wrong toolchain version on the runner
Autobuild picked a default JDK, .NET, or Go that does not match what the project needs, so compilation fails.
Dependencies or private feeds are not set up
Autobuild runs before you configure a private package feed or authenticate to it, so dependency resolution fails.
How to fix it
Provision the toolchain, then build manually
- Set up the exact language version your project needs before CodeQL init.
- Switch to
build-mode: manualand run your build commands explicitly. - Authenticate any private feeds in a step before the build.
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- uses: github/codeql-action/init@v3
with:
languages: java
build-mode: manual
- run: mvn -B -s settings.xml clean compileRead the autobuild log to find the failing command
The line before "Autobuild failed" names the actual failure (dependency, compiler, SDK). Fix that specific cause rather than retrying autobuild.
How to prevent it
- Pin and provision the toolchain version before the CodeQL job builds.
- Prefer manual build steps that mirror your normal CI build.
- Set up private package auth before the build runs.