How do I generating unique snapshots with gradle and Jenkins?

I’m trying to build a CI workflow in my company, using Gradle, Jenkins and Artifactory. I’m new to all of these, so there’s a chance I’m asking trivial questions.

I’ve setup my repository to use unique snapshots, which require the versions to have a 14 digit timestamp. For example:


But I’m having a hard time finding an easy way to generate these timestamps into the version. I was expecting that this would be automatically supported by either Jenkins or Gradle (I understand that Maven 3 has such a flow), but couldn’t find any reference to such a capability.

Am I supposed to code this in Gradle myself? Are there any best practices regarding how and when to do this? I’m assuming it only makes sense for this timestamp to happen for CI builds of snapshot versions, not for developer builds with local deploys or for release builds. Has anyone implemented something similar?

Gradle should automatically generate a unique version whenever you publish a snapshot. Alternatively, you can also configure Artifactory to do so.

Thanks Peter

This doesn’t seem to happen for me. My version property in is: 1.0.0-SNAPSHOT

When I build in Jenkins and deploy to artifactory, it tries to deploy with the same version number (without replacing SNAPSHOT with a timestamp). That fails due to the repository settings that only allow timestamped snapshots. Note that my repository isn’t maven, it’s set up more like an ivy repository (using the “gradle-default” layout in Artifactory).

Can you point me to which task / plugin / configuration I may need to look at?


Only works for Maven repos. Ivy doesn’t have a concept of snapshots. What you can do is to generate a version number yourself and refer to it with ‘latest.integration’ (I believe).