3

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'
Community
  • 1
  • 1
acabezas
  • 731
  • 1
  • 7
  • 20
  • What is your gradle file ? – Farmer Aug 26 '16 at 12:34
  • In you project contain duplicate script, show this answer http://stackoverflow.com/questions/29807622/gradle-artifactory-plugin-saying-cannot-cast-object-org-jfrog-gradle-plugin-ar or else share your project's gradle.build file – Farmer Aug 26 '16 at 13:12
  • In my project I just have that buildscript, i moved it to the master build.gradle. – acabezas Aug 27 '16 at 11:13
  • 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 Aug 28 '16 at 15:34
  • 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 Aug 29 '16 at 06:51
  • I can't reproduce this issue. I used the latest Jenkins Artifactory Plugin (2.6.0), with the following project example: – Eyal Ben Moshe Aug 29 '16 at 16:39
  • I can't reproduce this issue. I used the latest Jenkins Artifactory Plugin (2.6.0), with Jenkins 2.10 and the below project example (using version 4.4.3 of the Artifactory Plugin as a dependency in the build.gradle) https://github.com/JFrogDev/project-examples/tree/master/gradle-examples/4/gradle-example You can use the above example project to troubleshoot the issue. Also, I would try to delete Jenkins cache directory and then restart Jenkins (~/.jenkins/cache). – Eyal Ben Moshe Aug 29 '16 at 16:45
  • @EyalBenMoshe Thanks to your commets i have found the answer. The problem was that i was using the "Gradle-Artifactory Integration" in the jenkins job and also i was using the "com.jfrog.artifactory" plugin inside muy build.gradle script. that was generating a conflict. I will create a comlete answer about this later. Thanks! – acabezas Aug 31 '16 at 10:38

1 Answers1

0

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.

acabezas
  • 731
  • 1
  • 7
  • 20