3
votes

I am trying to use the JFrog Artifactory plugin in Jenkins but when I try to build the project. I get this error:

Failed to apply plugin [id 'com.jfrog.artifactory'] Cannot cast object
'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention@2f54f83b' 
with class 'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention' to class 
'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention'

I have already performed all the suggestions from answers to this and this similar questions, but still no luck.

I use Gradle v2.14.1, Artifactory plugin v2.6.0 and JFrog Artifactory v4.4.3

Edit:

this is the gradle file for my project

buildscript {
repositories {
    jcenter()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.2'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:1.2"
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.3"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {

TAG = "v" + "$VERSION_NAME" + "#" + String.format("%06d", Integer.parseInt("$VERSION_CODE"))
repositories {
    jcenter()
    maven {
        url "https://plugins.gradle.org/m2/"
    }

}
}


task clean(type: Delete) {
delete rootProject.buildDir
}

apply from: 'sonar.gradle'
1
What is your gradle file ?Shailesh
In you project contain duplicate script, show this answer stackoverflow.com/questions/29807622/… or else share your project's gradle.build fileShailesh
In my project I just have that buildscript, i moved it to the master build.gradle.acabezas
I assume that you're not applying the "com.jfrog.artifactory" plugin inside your gradle script, but instead you let Jenkins apply it (by un-checking the "Project uses the Artifactory Gradle Plugin" check box in the Jenkins job UI). If this is the case, please try removing the following line from your build script, because it may collide with the Gradle Artifactory Plugin version used by Jenkins.Eyal Ben Moshe
EyalBenMoshe I do apply the "com.jfrog.artifactory" plugin inside muy build.gradle script and also I have checked the "Gradle-Artifactory Integration" check Box in the jenkins job UI in the build environment block.acabezas

1 Answers

0
votes

thanks to the comments of EyalBenMoshe I realised that that problem was That i was using the JFrog Artifactory v4.4.3 plugin in my build.gradle files and I also was using the Artifactory plugin v2.6.0 in my jenkins, so they where colliding. the solution was to remove the JFrog Artifactory v4.4.3 plugin from my build.gradle.