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: https://github.com/lordofthejars/starwars/blob/master/build.gradle#L112

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