All steps required are below.
- remove '-SNAP' suffix from the version and commit to git repo
- create new git tag on this commit
- Artifactory Deploy on Jfrog with release version not with -SNAP version
- bump version in build.gradle (like pom.xml), and add '-SNAP' suffix.
I used the most popular Gradle Release Plugin (https://github.com/researchgate/gradle-release) but not able to deploy artifactory on Jfrog with release version (it's always taking SNAP version).
Below is my sample code...
gradle.build file
publishing {
publications {
mavenJava(MavenPublication) {
groupId 'in.org'
artifactId 'some-service'
version "${version}"
from components.java
}
}
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = version.endsWith('SNAP') ? "${snapshot_repository}" : "${release_repository}"
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications("mavenJava")
publishArtifacts = true
publishPom = true
}
}
resolve {
repository {
repoKey = "${release_repository}"
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
release {
versionPropertyFile = 'gradle.properties'
failOnCommitNeeded = false
failOnPublishNeeded = false
git {
requireBranch.set('release')
}
}
artifactoryDeploy.shouldRunAfter preTagCommit, checkCommitNeeded
updateVersion.doLast {
def buildGradle = file('gradle.properties')
buildGradle.text = buildGradle.text.replaceFirst(~/version = (\d++\.\d++\.\d++)/, 'version = \'$1\'')
}
gradle.properties file
artifactory_user=*****
artifactory_password=*****
artifactory_contextUrl=https://jfrog.in/artifactory
version=1.0.1-SNAPSHOT
snapshot_repository=gradle-dev-local
release_repository=gradle-release-local