发布Maven构件后无法查看构建记录的技术咨询
Hey there! I totally get how frustrating it is to go through all the setup steps, deploy your artifact, and then not see the build record show up. Let's walk through the most common fixes for this issue—these are the same checks I do when I run into this kind of problem:
1. Make Sure Build Integration is Enabled in Your Maven Setup
Artifactory doesn't automatically track builds unless you explicitly tell it to. The easiest way to fix this is to add the Artifactory Maven Plugin to your pom.xml (or use command-line parameters when deploying):
Option 1: Add the Plugin to Your pom.xml
Add this inside the <build><plugins> section of your project's pom:
<plugin> <groupId>org.jfrog.buildinfo</groupId> <artifactId>artifactory-maven-plugin</artifactId> <version>3.2.2</version> <!-- Use the latest stable version --> <executions> <execution> <id>publish-build-info</id> <goals> <goal>publish</goal> </goals> <configuration> <publisher> <contextUrl>https://your-artifactory-instance-url/artifactory</contextUrl> <username>${artifactory.username}</username> <password>${artifactory.password}</password> <repoKey>your-target-local-repo</repoKey> <!-- Match the repo in distributionManagement --> <buildName>your-project-build-name</buildName> <!-- Pick a name for your build --> <buildNumber>${project.version}</buildNumber> <!-- Use your version or a build number --> </publisher> </configuration> </execution> </executions> </plugin>
Option 2: Use Command-Line Parameters
If you don't want to modify your pom, pass these flags when running mvn deploy:
mvn deploy -Dbuild.name=your-project-build -Dbuild.number=1.0.0 -Dartifactory.username=your-username -Dartifactory.password=your-api-key
Pro tip: Use your Artifactory API Key instead of your password—you can generate this in your Artifactory user profile settings.
2. Verify Your settings.xml Configuration
Double-check that your ~/.m2/settings.xml has the right setup:
- The
<server>id must match the id in yourdistributionManagementsection of the pom. - Ensure the server has the correct username and API key/password.
- Make sure you've added the Artifactory repository mirrors if needed (though this isn't strictly required for build records, it helps with dependency resolution).
Example server section in settings.xml:
<servers> <server> <id>your-artifactory-repo-id</id> <username>your-username</username> <password>your-api-key</password> </server> </servers>
3. Check the Deploy Command's Debug Log
Run the deploy with debug logging enabled to see what's going on under the hood:
mvn deploy -X
Look for lines mentioning "build info" or calls to Artifactory's build API. If you see errors like 401 Unauthorized, that means your credentials are wrong. If there's no mention of build info being published, that confirms the build integration isn't set up correctly.
4. Check Artifactory UI Filters and Repository Settings
- Filter correctly: Go to the Artifactory UI's Builds tab. Make sure you're not filtering by the wrong build name or status. Try selecting "All Builds" to see if your record shows up.
- Verify repository configuration: Ensure the local repository you're deploying to has Build Integration enabled. You can check this in Artifactory's Admin > Repositories > Local > [Your Repo] > Advanced Settings.
5. Confirm You're Deploying to a Local Repository
Virtual or remote repositories don't store build records—you need to deploy to a local repository. Double-check your distributionManagement section in the pom to make sure the repo URL points to a local repo in your Artifactory instance.
Once you've tried these steps, redeploy your artifact and check the Builds tab again. In most cases, enabling the build integration plugin or passing the command-line flags will fix the missing build records issue.
内容的提问来源于stack exchange,提问作者Anya

