Could you clarify you question? If you are at the point that you are running a .OpenSpan file then your build has already completed.
If you are building your automation with Jenkins, then MSBuild will return with a non-zero exit code if the build fails, which should automatically fail the job being run. The same is true if you are using the OSD tool to create deployment files.
DannyF72: When I am triggering any build from Jenkins using the above command, the status in Jenkins is always "build failed" irrespective of the status of the build in the local. I want to know how to control this and pass the right status in Jenkins.
Jenkins will fail a job if a command that you run returns a non zero exit code. You may be able to write a batch script that will execute that runtime call and always return a 0. There are plenty of resources online to help you right this. You may want to start with a simple script like this and see if it works.
Keep in mind, if the runtime is returning a non-zero exit code than it's a pretty strong indication that something is not working properly. I would try to resolve that first instead of trying to suppress the error (if something really does go wrong you would never know).
Here are a few suggestions:
Ensure that the .OpenSpan automation file you are trying to execute exists on the machine. What you showed is an absolute file path to something that may not be there. You may want to consider bundling the .OpenSpan and .manifest file with the Jenkins job you are running and accessing through a relative path.
Make sure the .manifest file is in the same directory as the .OpenSpan file you are running.
See if there is anything more meaningful in the logs for the jenkins job.
Check the runtime logs on the build agent to see if there are any errors/exceptions happening that would cause the runtime to crash.
Log onto the build agent and run that OpenSpan command to see if it fails. If it runs fine, there may be an issue with running OpenSpan under the Jenkins service. If the Jenkins service is running under a different windows account than what you tested with, make sure the other account has all the access it may need in your organization to execute the automation you are trying to run.
Run a Jenkins build agent on your local machine. Launch it from the command line, logged in under your account, connect the local agent to your Jenkins server, and make the build run on your machine. See if the automation is running properly. If so, there may be an issue with the account Jenkins is running under (like I stated above) or the build agent it is running on.