Jenkins exposes these to Gradle in the form of environment variables. Therefore you can access them in your Gradle build script as System.env.BUILD_NUMBER.
This is because the BUILD_NUMBER environment variable does not exist in your local environment. (see the System API)
If your Gradle build is executed in Jenkins and also locally, you have to be sure to
either create the BUILD_NUMBER environment variable in your local environment as well (if you plan to use it as well for a local build, which is questionable)
add custom logic to avoid putting this information in the manifest when executing a local build
How was it done before your transition to Gradle ?
Using my own experience, at work we have a boolean property (userIsCiServer) which is sets to true only if Gradle is executed from Jenkins. This allows to have two distincts behaviors, whether the build is executed locally or in jenkins.
A simple approach could be to simply check for the presence of the BUILD_NUMBER environment variable before using it, with something like
System.env.contains('BUILD_NUMBER')
or simply using Groovy String coercion
if(System.env.BUILD_NUMBER){
// add the stuff you want in your manifest
}