2
votes

I'm using Gradle and Jenkins and want to deploy artifacts to Artifactory. Unfortunately this deployment works only once, when I start the build in Jenkins.

If I delete the workspace and the ~/.gradle Folder on the Jenkins server the deployment works again. Deleting only the workspace alone is not enough.

Seems like a bug for me. Do I have any unknown version conflicts. Or is it something different I don't see. Thanks for any help.

Environment:

  • Jenkins 2.7.3
  • Gradle 3.1
  • Artifactory 4.13.0
  • Jenkins Artifactory Plugin 2.7.2

Gradle Build Script: (Based on example from jfrog)

buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '4.4.5')
  }
}

allprojects {
  apply plugin: 'java'
  apply plugin: 'maven-publish'

  repositories {
    jcenter()
  }

  group = 'org.jfrog.example.gradle'
  version = '1.0.1-SNAPSHOT'
  status = 'integration'
}

artifactory {
  publish {
    defaults {
        publishConfigs('archives')
    }
  }
}

// Setting this property to true will make the artifactoryPublish task
// skip this module (in our case, the root module):
artifactoryPublish.skip = true

Jenkins Artifactory Plugin Settings:

  • [x] Gradle-Artifactory-Integration
  • [x] Capture and publish build info
  • [x] Publish artifacts to Artifactory
  • [x] Publish Maven Descriptors
  • [x] Use Maven compatible Patterns

Rest is deactivated (not set).

Log in Jenkins (Console Output), on second run with changed version and changed source code:

Jenkins Artifactory Plugin version: 2.7.2
[Gradle] - Launching build.
[CdExampleArtifactory] $ cmd.exe /C '""C:\Program Files (x86)\Jenkins\tools\gradle-3.1\bin\gradle.bat"' --init-script c:/temp/init-artifactory8368571638486556211gradle artifactoryPublish && exit %%ERRORLEVEL%%"
:artifactoryPublish
:api:artifactoryPublish
:services:artifactoryPublish
:shared:artifactoryPublish
:services:webservice:artifactoryPublish

BUILD SUCCESSFUL

Total time: 2.422 secs
Build step 'Invoke Gradle script' changed build result to SUCCESS
Finished: SUCCESS

It looks like the task don't start the build (jar, etc.) process.

2
are you running gradle build in your jenkins job somewhere?RaGe
yes, build runs as task. If I delete ~/.gradle then build will be called anyway if I set it as task or not. At the second run artifactoryPublish does nothing regardless if build is configured or not.Reinhard

2 Answers

3
votes

Using the latest Gradle Artifactory Plugin version 4.4.7 solves the compatibility issue with Gradle 3.1.

Gradle build snippet:

buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '4.4.7')
  }
}

Note the version.

0
votes

I found a solution for my problem.

I have to deactivate the gradle deamon on the jenkins server (via GRADLE_OPTS).