I am trying to deploy a project jar into JFrog Artifactory using gradle. The build.gradle
file looks like this (the part necessary for deploy):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.16.1"
}
configurations.classpath {
resolutionStrategy {
cacheDynamicVersionsFor 0, 'seconds'
cacheChangingModulesFor 0, 'seconds'
}
}
}
plugins {
id 'java'
id 'com.jfrog.artifactory' version '4.16.1'
id 'maven-publish'
}
repositories {
mavenCentral()
mavenLocal()
repositories {
mavenCentral()
maven {
url "<artifactoryPath>/artifactory/gcc-maven/"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId group
version version
from components.java
}
}
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'gcc-maven-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications('mavenJava')
publishArtifacts = true
properties = ['version': version, 'dev.team': '<project>']
publishPom = true
}
}
resolve {
repository {
repoKey = 'gcc-maven'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
When I use my username and password everything works fine but when I use a token the .jar .module and .pom files are pushed but not the build descriptor. I have the next error:
> Task :artifactoryDeploy
Deploying build descriptor to: <artifactoryPath>/artifactory/api/build
Could not build the build-info object.
java.io.IOException: Failed to send build descriptor. 403 Response message: {
"errors" : [ {
"status" : 403,
"message" : "User token:fim-artifactory-gcc-maven-rw-token is not permitted to deploy '<name>.json' into '<name>.json'."
} ]
}
The token looks like this:
{
"scope" : "member-of-groups:fim-artifactory-gcc-maven api:*",
"access_token" : "<very_long_string>",
"expires_in" : 0,
"token_type" : "Bearer"
}
Some sites suggest that is a checkbox Any Build that must be checked but I don't find it and I think it might be a problem with build.gradle file.
What am I doing wrong? It's there any possibility to skip the build descriptor at all?
I found out in artifactory gradle documentation that build descriptor can be ignored by setting publishBuildInfo
to false
in the defaults section. In my case it was what I was looking for.