jfrog / jenkins-artifactory-plugin

Jenkins artifactory plugin
http://jenkins-ci.org/
116 stars 190 forks source link

Artifactory plugin does not publish any artifact but just the build descriptor #168

Open antonalechnovic opened 5 years ago

antonalechnovic commented 5 years ago

Considering minimalist build.gradle:

plugins {
    id 'java'
    id 'base'
    id "com.jfrog.artifactory" version "4.9.7"
}

apply plugin:'base'
apply plugin: "com.jfrog.artifactory"
apply plugin: 'java'
apply plugin: 'maven-publish'

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}

repositories {
    jcenter()
}

group = 'com.bla.test'
version = '1.1'
sourceCompatibility = '1.8'

Using tutorial: https://www.jfrog.com/confluence/display/RTF/Gradle+Builds

with Gradle wrapper 5.5.1

And Jenkins version: 2.107.3

And Jenkins Artifactory Plugin version: 3.2.1

On running the job as in the link:

Fetching upstream changes from git@github.com:xxx/xxx-spring.git
 > git --version # timeout=10
using GIT_SSH to set credentials github-xxx-key
 > git fetch --tags --progress git@github.com:xxx/xxx-spring.git +refs/heads/*:refs/remotes/origin/*
 > git config remote.origin.url git@github.com:xxx/nxxx-spring.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url git@github.com:xxxinc/xxx-spring.git # timeout=10
Fetching upstream changes from git@github.com:xxxinc/xxx-spring.git
using GIT_SSH to set credentials github-chatapp-key
 > git fetch --tags --progress git@github.com:xxxinc/xxx-spring.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/xxx^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/xxx^{commit} # timeout=10
Checking out Revision xxx8fc4cf1fe4531bdb4b52d83ce (refs/remotes/origin/try-gradle)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f xxx8fc4cf1fe4531bdb4b52d83ce
Commit message: "FML 2"
 > git rev-list --no-walk xxx8fc4cf1fe4531bdb4b52d83ce # timeout=10
Jenkins Artifactory Plugin version: 3.2.1
[gradle_library_publish] $ /bin/sh -xe /tmp/jenkins3752614823280854506.sh
+ cd monitoring
[Gradle] - Launching build.
[monitoring] $ /var/lib/jenkins/workspace/some_job/xxx/gradlew -scan -s clean artifactoryPublish
> Task :clean UP-TO-DATE
> Task :artifactoryPublish

> Task :artifactoryDeploy
Deploying build descriptor to: http://xxxx.internal/xxxx/api/build
Build successfully deployed. Browse it in Artifactory under http://xxxx.internal/xxxx/webapp/builds/gradle_library_publish/28

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1s
3 actionable tasks: 2 executed, 1 up-to-date

The build scan was not published due to a configuration problem.

The Gradle Terms of Service have not been agreed to.

For more information, please see https://gradle.com/scans/help/plugin-terms-of-service.

Alternatively, if you are using Gradle Enterprise, specify the server location.
For more information, please see https://gradle.com/scans/help/plugin-enterprise-config.

Build step 'Invoke Gradle script' changed build result to SUCCESS
Finished: SUCCESS

This does not publish anything but the build descriptor

Everything works fine when trying to publish locally to artifactory but that needs

descriptor with url and everything set. When trying to run the job with this descriptor it also works. I thought that entire purpose of jenkins plugin is to eliminate that. Please help. The job itself has configured repositories and credentials and has "Publish artifacts to Artifactory" checked.
antonalechnovic commented 5 years ago

Additionally the sample project doesn't even run: https://github.com/jfrog/project-examples/tree/master/gradle-examples/gradle-example-ci-server this is mess

willis7 commented 5 years ago

I'm not sure if it's related but on my multi-project build I get

No artifacts for deployment were found

willis7 commented 5 years ago

I managed to resolve this - the documentation isnt clear. The bit that I was missing was the publishingblock in each of my subprojects. As soon as I added that, everything worked.

MarsPlanet commented 4 years ago

@willis7 can you paste the solution

tmaxted commented 4 years ago

@MarsPlanet not sure if you figured it out in the end but here is my solution;

Using the 'maven-publish' plugin:

apply plugin: "java"
apply plugin: "com.jfrog.artifactory"
apply plugin: "maven"
...
publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            artifactId = rootProject.name
            // you may have to assign version here
        }
    }
}

Then add the publication to the default publish:

artifactory {
    publish {
        ...
        defaults {
            publications("mavenJava")
            ...
        }
    }
}

Using the 'maven' plugin:

You can make the artifactoryPublish task depend on the build and the tell the default publish to publish the configs:

apply plugin: "java"
apply plugin: "com.jfrog.artifactory"
apply plugin: "maven-publish"
...

artifactoryPublish {
    dependsOn build
}

artifactory {
    publish {
        ...
        defaults {
            publishConfigs("archives", "published") // I'm not actually sure what config's to put here, but these work for me 😅 
            ...
        }
    }
}

Also I found sometimes doing a 'clean build artifactoryPublish' works, when 'build artifactoryPublish' does not.