Generating build number through gradle

Gradle.properties:

artifactMajorVersion=1.0.1
artifactBuildNumber=0

and also including below lines in build.gradle script:

String current = "$artifactBuildNumber"
artifactBuildNumber = artifactBuildNumber.toInteger()
// artifactBuildNumber = artifactBuildNumber.toInteger() + 1
logger.info "Incrementing build number: $current -> $artifactBuildNumber"
ant.propertyfile(file: file(‘gradle.properties’)) {
entry(key: ‘artifactBuildNumber’, type: ‘int’, operation: ‘+’, value: 0)
}
archiveName project.get(‘bluemix_server_zip_name’) + “" + “$artifactMajorVersion” + "” + “$artifactBuildNumber” + “.zip”
}

Now it is generating the build with major and minor build number. And with every build minor build is being increamented with 1.

Now I want to start with lower number(0) for minor build number again when I update the major build number this is not happening.

I am not sure where the variables are store and how to re-initialize it in gradle

What variables are you referring to?