You’re running your Maven steps in the wrong order:
clean– delete all previous build outputsonar:sonar– run analysis (which requires build output)deploy– build &etc…
Try this instead:
mvn clean deploy sonar:sonar
Now if you’re about to object that you don’t want to actually “deploy” the jar until/unless the changed code passes the Quality Gate, well… that requires a different workflow:
mvn clean package sonar:sonar
// check quality gate status
// if (qualityGateOk) { deploy }
The particulars of those last two steps will depend on your CI infrastructure. But for Jenkins, step #2 is well documented