Fix false failure status when running Maven without deploy goal#293
Conversation
When running 'jf mvn clean package --detailed-summary' with a deployer configured, the CLI incorrectly reported a failure status even though Maven reported BUILD SUCCESS. This happened because artifacts were counted as 'deployment failures' when no deployment was requested. This fix checks if the user explicitly requested deployment by looking for the 'deploy' goal in the Maven command. If no deploy goal is present, deployment is disabled, preventing false failure reporting. Fixes: RTECO-453
If deployer is set and artifacts are getting created either via package | verify | install goals then isn't jfrog-cli automatically trying to deploy artifacts? If some customers are using this combination of install and deployer or package and deployer and expects the artifacts to be ployed then this will be regression. |
| // Maven's extractor deploys build artifacts. This should be disabled since there is no intent to deploy anything or deploy upon Xray scan results. | ||
| mc.deploymentDisabled = mc.IsXrayScan() || !vConfig.IsSet("deployer") | ||
| // Also disable deployment if the user didn't explicitly request it (no "deploy" goal in the command). | ||
| mc.deploymentDisabled = mc.IsXrayScan() || !vConfig.IsSet("deployer") || !mc.isDeploymentRequested() |
There was a problem hiding this comment.
without this are we trying to deploy to artifactory? even without mentioning deploy? can you test for mvn install and check if that is the case?
Preserves backward compatibility while fixing unwanted deployments: - 'jf mvn install': Deploys to Artifactory (backward compatible) - 'jf mvn deploy': Deploys to Artifactory (standard behavior) - 'jf mvn package/compile/verify': NO deployment + warning message When deployer is configured but non-deploying goal is used, shows warning: 'Deployer repository is configured but Maven goal does not trigger deployment. Only install and deploy goals will deploy artifacts to Artifactory.' Fixes: RTECO-453, GitHub #2602
d8c78a2 to
496e665
Compare
artifactory/commands/mvn/mvn.go
Outdated
| if vConfig.IsSet("deployer") && !mc.IsXrayScan() { | ||
| if !mc.deploymentDisabled { | ||
| log.Info("Deployer repository is configured and deployment goal detected - artifacts will be deployed to Artifactory") | ||
| } else { | ||
| log.Warn("Deployer repository is configured but Maven goal does not trigger deployment. Only 'install' and 'deploy' goals will deploy artifacts to Artifactory.") | ||
| } | ||
| } |
There was a problem hiding this comment.
@bhanurp let me know if we need any logs improvement here.
There was a problem hiding this comment.
ScanDeployableArtifacts() returns both fileSpec and pom.xml values as nil and with an error only then can we warn and return cli with exit code 0?
artifactory/commands/mvn/mvn.go
Outdated
| if !mc.deploymentDisabled { | ||
| log.Info("Deployer repository is configured and deployment goal detected - artifacts will be deployed to Artifactory") | ||
| } else { | ||
| log.Warn("Deployer repository is configured but Maven goal does not trigger deployment. Only 'install' and 'deploy' goals will deploy artifacts to Artifactory.") | ||
| } |
There was a problem hiding this comment.
| if !mc.deploymentDisabled { | |
| log.Info("Deployer repository is configured and deployment goal detected - artifacts will be deployed to Artifactory") | |
| } else { | |
| log.Warn("Deployer repository is configured but Maven goal does not trigger deployment. Only 'install' and 'deploy' goals will deploy artifacts to Artifactory.") | |
| } | |
| if mc.deploymentDisabled { | |
| log.Warn("Deployer repository is configured but Maven goal does not trigger deployment. Only 'install' and 'deploy' goals will deploy artifacts to Artifactory.") | |
| } |
- Clarifies that install goal still deploys (preserving backward compatibility) - Documents warning messages for non-deploying goals - Updates examples and test results - Emphasizes goal-based deployment control
496e665 to
604c65f
Compare

Description
GitHub Issue: jfrog/jfrog-cli#2602
This fix introduces intelligent goal detection to control when artifacts are deployed to Artifactory, while preserving backward compatibility for existing workflows.
Problem: Previously, when a deployer was configured, ALL Maven commands would deploy artifacts, regardless of the Maven goal used.
Solution: Only
installanddeploygoals trigger deployment. Other goals (likecompile,package,verify) do not deploy, with a clear warning message.Before Fix:
$ jf mvn package --detailed-summary # Result: Deploys to Artifactory (unwanted!)After Fix:
$ jf mvn package --detailed-summary 15:36:35 [Warn] Deployer repository is configured but Maven goal does not trigger deployment. Only 'install' and 'deploy' goals will deploy artifacts to Artifactory. [main] INFO ... deploy artifacts set to false, artifacts will not be deployed... [main] INFO ... BUILD SUCCESS # Result: No deployment, clear warning messageGoal-Based Deployment Control
Helper Function
Testing
Test 1: Maven Without Deploy Goal (Bug Scenario -
mvn install)Before Fix:
After Fix:
Test 2: Maven With Deploy Goal (Existing Functionality)
Before and After (No change - works correctly):
$ jf mvn clean deploy --detailed-summary { "status": "success", "totals": { "success": 2, "failure": 0 }, "files": [...] } # Exit code: 0Test 3: FlexPack Mode
Before and After (No change - unaffected):
$ JFROG_RUN_NATIVE=true jf mvn clean package --build-name=test --build-number=1 # Result: No JSON, exit code 0Warning Message
When a deployer is configured but a non-deploying goal is used: