Travis构建后部署Spring Boot至GCP App Engine遇ArtifactNotFound错误求助
That error means the GCP App Engine builder can’t locate your compiled Spring Boot jar file—let’s break down how to fix this step by step.
1. Ensure Your Spring Boot Project Generates a Deployable Jar
First, double-check your pom.xml has the Spring Boot Maven Plugin configured correctly to create an executable, self-contained jar. This plugin repackages your build output into a format GCP can run:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
When you run mvn package, this will generate a jar file in the target/ directory (usually named like your-app-name-1.0.0.jar).
2. Update Your Travis CI Configuration
Your current .travis.yml only handles building the project—it’s missing critical deployment steps for GCP and settings to preserve your build artifact. Here’s a complete, updated version:
sudo: false language: java jdk: - oraclejdk8 cache: directories: - "$HOME/.m2/repository" before_install: # Install Google Cloud SDK and required components - curl https://sdk.cloud.google.com | bash > /dev/null; - source $HOME/google-cloud-sdk/path.bash.inc - gcloud components install app-engine-java - gcloud components update # Decrypt your GCP service account key (replace with your encrypted file name) - openssl aes-256-cbc -K $encrypted_XXXX_key -iv $encrypted_XXXX_iv -in service-account-key.json.enc -out service-account-key.json -d script: # Build the jar (skip tests if needed, but ensure package runs) - mvn clean package -DskipTests deploy: provider: gae keyfile: service-account-key.json project: YOUR_GCP_PROJECT_ID # Replace with your actual project ID artifact: target/*.jar # Explicitly point to the jar in target/ skip_cleanup: true # Critical! Prevents Travis from deleting your jar before deployment
Key Config Details:
skip_cleanup: true: This is the most common oversight—Travis automatically cleans build artifacts after thescriptphase unless you disable this.artifact: target/*.jar: Explicitly tells the GCP deployer where to find your jar, avoiding path mismatches.- GCP Authentication: You’ll need to encrypt your GCP service account key using
travis encrypt-file service-account-key.json(replace with your key file) and add the generatedencrypted_XXXX_keyandencrypted_XXXX_ivvariables to your Travis environment.
3. Verify Your App Engine Configuration
If you’re using a custom app.yaml (required for flexible environments, optional for standard), make sure it points to the correct jar:
# For Java 8 standard environment runtime: java8 entrypoint: java -jar target/your-app-name.jar # Or for Java 11 flexible environment runtime: java11 entrypoint: java -jar target/your-app-name.jar
Match the entrypoint path to the actual jar name in your target/ directory.
4. Troubleshooting Checks
- Review your Travis build logs to confirm
mvn packageruns successfully and creates the jar intarget/. - Check the GCP deployment logs to see exactly which paths the builder is checking—this can reveal mismatches in the jar name or directory.
- Ensure your GCP service account has the App Engine Deployer role to grant deployment permissions.
内容的提问来源于stack exchange,提问作者Stefan Gies

