Publish Maven plugin ignores custom version

Hello, I am developing a web project in Gradle which overrides the version of the artifacts to reflect the build number of Jenkins.
This logic works perfectly when I run gradlew asssemble, generating a war file with -1.0.. The problem is that when I call gradlew publish, what I get published is the artifacts without the buildnumber -1.0, like if the logic of setting the version is not called. And the same happens with sources and javadoc.

You can see code here:

You only need to use project.version in and be sure that Jenkins set the environment variable for all calls to assemble and publish tasks.