Here is the explanation from the Cloud Foundry docs ...
How cf push Finds the Application
By default, cf push recursively
pushes the contents of the current working directory. Alternatively,
you can provide a path using either a manifest or a command line
option.
If the path is to a directory, cf push recursively pushes the contents
of that directory instead of the current working directory. If the
path is to a file, cf push pushes only that file.
Note: If you want to
push more than a single file, but not the entire contents of a
directory, consider using a .cfignore file to tell cf push what to
exclude.
Source: https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html
Based on this description, your jar file will get pushed. If you want to stop it getting pushed, you could create a temporary .cfignore
file, something like this:
if [[ condition ]]; then
echo my.jar > .cfignore
bx cf push
rm -f .cfignore
else
rm -f .cfignore
bx cf push
fi
If you already have a .cfignore
you your logic will need to either remove or add your jar file to it.