jfrog / jfrog-cli

JFrog CLI is a client that provides a simple interface that automates access to the JFrog products.
https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
Apache License 2.0
531 stars 234 forks source link

Android - .aar Artifacts not deployed with latest release (1.40.0) #880

Open sebasira opened 4 years ago

sebasira commented 4 years ago

Describe the bug I've been using for a long time a GitLab CI/CD script to upload artifacts to Artifactory. Suddenly, the artifacts were not deployed, with no errors or warning. I came here to check and I notice you've created a new release 3days ago. And the last time a deploy succeed was indeed 3days ago.

To Reproduce Here's part of the GitLab YAML script I'm using:

.install_gradle: &install_gradle |
  curl -L https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-all.zip -o gradle.zip
  unzip -q gradle.zip
  export GRADLE_HOME=$(pwd)/gradle-$GRADLE_VERSION
  export PATH=${GRADLE_HOME}/bin:${PATH}
  echo $GRADLE_HOME
  echo $PATH
  gradle -v

.connect_artifactory: &connect_artifactory |
  curl -fL https://getcli.jfrog.io | sh -s v1.39.7
  ./jfrog rt config --url=$ARTIFACTORY_URL --user=$ARTIFACTORY_USER --password=$ARTIFACTORY_PASS
  ./jfrog rt c show

.upload_artifact: &upload_artifact |
  ./jfrog rt gradle-config --use-wrapper=true --repo-resolve=$GRADLE_REPO_KEY --server-id-resolve=Default-Server --repo-deploy=$GRADLE_REPO_KEY --server-id-deploy=Default-Server
  ./jfrog rt gradle clean artifactoryPublish -b build.gradle --build-name=$ARTIFACT_NAME --build-number=$CI_JOB_ID

# JOB:
publish:
  stage: deploy
  cache: {}
  script:
    # Download and Install Gradle
    - *install_gradle
    # Connect to JFrog Artifactory
    - *connect_artifactory
    # Replace the repository name in the configuration.yml to the correct one.
    - sed -i 's,GRADLE_REPO_KEY,'"$GRADLE_REPO_KEY"',g' configuration.yaml
    # Upload artifact to JFrog Artifactory
    - *upload_artifact

Expected behavior The artifact should be uploaded/deplyed to Artifactory

Screenshots Instead of screenshot I can provide logs from GitLab CI/CD Job. One think I've notice is that when the deployment was working the logs were much bigger, it seems like some gradle task were not executing

Log when the deployment work:

------------------------------------------------------------
Gradle 5.6.4
------------------------------------------------------------

Build time:   2019-11-01 20:42:00 UTC
Revision:     dd870424f9bd8e195d614dc14bb140f43c22da98

Kotlin:       1.3.41
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM:          11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OS:           Linux 4.4.0-190-generic amd64

$ curl -fL https://getcli.jfrog.io | sh # collapsed multi-line command
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   178  100   178    0     0    528      0 --:--:-- --:--:-- --:--:--   528

100  1344  100  1344    0     0   3490      0 --:--:-- --:--:-- --:--:--  3490
Downloading the latest version of JFrog CLI...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100 19.0M  100 19.0M    0     0  24.8M      0 --:--:-- --:--:-- --:--:-- 24.8M
[Info] Encrypting password...
Server ID: Default-Server
Url: <myArtifactoryURL>
User: <myArtifactoryUser>
Password: <myPass>
Default:  true

$ sed -i 's,GRADLE_REPO_KEY,'"$GRADLE_REPO_KEY"',g' configuration.yaml
$ ./jfrog rt gradle-config --use-wrapper=true --repo-resolve=$GRADLE_REPO_KEY --server-id-resolve=Default-Server --repo-deploy=$GRADLE_REPO_KEY --server-id-deploy=Default-Server # collapsed multi-line command
[Info] gradle build config successfully created.
[Info] Downloading bintray/jcenter/org/jfrog/buildinfo/build-info-extractor-gradle/4.15.2/build-info-extractor-gradle-4.15.2-uber.jar
[Info] Downloaded 1 artifact.
[Info] Running gradle command: ./gradlew --init-script /root/.jfrog/dependencies/gradle/4.15.2/gradle.init clean artifactoryPublish -b build.gradle
Downloading https://services.gradle.org/distributions/gradle-5.6.4-all.zip
.....................................................................................................................................
Unzipping /builds/sebasira/android-module-boilerplate/.gradle/wrapper/dists/gradle-5.6.4-all/ankdp27end7byghfw1q2sw75f/gradle-5.6.4-all.zip to /builds/sebasira/android-module-boilerplate/.gradle/wrapper/dists/gradle-5.6.4-all/ankdp27end7byghfw1q2sw75f
Set executable permissions for: /builds/sebasira/android-module-boilerplate/.gradle/wrapper/dists/gradle-5.6.4-all/ankdp27end7byghfw1q2sw75f/gradle-5.6.4/bin/gradle
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/5.6.4/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
Cannot publish pom for project ':app' since it does not contain the Maven plugin install task and task ':app:artifactoryPublish' does not specify a custom pom path.
No publish configurations specified for project ':' and the default 'archives' configuration does not exist.
Compatible side by side NDK version was not found for android.ndkVersion '21.3.6528147'
Checking the license for package NDK (Side by side) 21.3.6528147 in /sdk/licenses
License for package NDK (Side by side) 21.3.6528147 accepted.
Preparing "Install NDK (Side by side) 21.3.6528147 (revision: 21.3.6528147)".
"Install NDK (Side by side) 21.3.6528147 (revision: 21.3.6528147)" ready.
Installing NDK (Side by side) 21.3.6528147 in /sdk/ndk/21.3.6528147
"Install NDK (Side by side) 21.3.6528147 (revision: 21.3.6528147)" complete.
"Install NDK (Side by side) 21.3.6528147 (revision: 21.3.6528147)" finished.
Checking the license for package CMake 3.6.4111459 in /sdk/licenses
License for package CMake 3.6.4111459 accepted.
Preparing "Install CMake 3.6.4111459 (revision: 3.6.4111459)".
"Install CMake 3.6.4111459 (revision: 3.6.4111459)" ready.
Installing CMake 3.6.4111459 in /sdk/cmake/3.6.4111459
"Install CMake 3.6.4111459 (revision: 3.6.4111459)" complete.
"Install CMake 3.6.4111459 (revision: 3.6.4111459)" finished.
Checking the license for package Android SDK Build-Tools 28.0.3 in /sdk/licenses
License for package Android SDK Build-Tools 28.0.3 accepted.
Preparing "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)".
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" ready.
Installing Android SDK Build-Tools 28.0.3 in /sdk/build-tools/28.0.3
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" complete.
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" finished.
Checking the license for package Android SDK Platform 29 in /sdk/licenses
License for package Android SDK Platform 29 accepted.
Preparing "Install Android SDK Platform 29 (revision: 5)".
"Install Android SDK Platform 29 (revision: 5)" ready.
Installing Android SDK Platform 29 in /sdk/platforms/android-29
"Install Android SDK Platform 29 (revision: 5)" complete.
"Install Android SDK Platform 29 (revision: 5)" finished.
> Task :clean UP-TO-DATE
> Task :app:externalNativeBuildCleanDebug
> Task :app:externalNativeBuildCleanRelease
> Task :app:clean UP-TO-DATE
> Task :app:preBuild UP-TO-DATE
> Task :app:preReleaseBuild UP-TO-DATE
> Task :app:compileReleaseAidl NO-SOURCE
> Task :app:compileReleaseRenderscript NO-SOURCE
> Task :app:checkReleaseManifest
> Task :app:generateReleaseBuildConfig
> Task :app:generateReleaseResValues
> Task :app:generateReleaseResources
> Task :app:packageReleaseResources
> Task :app:parseReleaseLibraryResources
> Task :app:processReleaseManifest
> Task :app:generateReleaseRFile
> Task :app:javaPreCompileRelease

> Task :app:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :app:extractReleaseAnnotations
> Task :app:mergeReleaseGeneratedProguardFiles
> Task :app:mergeReleaseConsumerProguardFiles
> Task :app:mergeReleaseShaders
> Task :app:compileReleaseShaders
> Task :app:generateReleaseAssets
> Task :app:packageReleaseAssets
> Task :app:packageReleaseRenderscript NO-SOURCE
> Task :app:prepareLintJarForPublish
> Task :app:processReleaseJavaRes NO-SOURCE
> Task :app:mergeReleaseJavaResource
> Task :app:transformClassesAndResourcesWithSyncLibJarsForRelease

> Task :app:generateJsonModelRelease
release|armeabi-v7a :-- Check for working C compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
release|armeabi-v7a :-- Check for working C compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
release|armeabi-v7a :-- Detecting C compiler ABI info
release|armeabi-v7a :-- Detecting C compiler ABI info - done
release|armeabi-v7a :-- Detecting C compile features
release|armeabi-v7a :-- Detecting C compile features - done
release|armeabi-v7a :-- Check for working CXX compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
release|armeabi-v7a :-- Check for working CXX compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
release|armeabi-v7a :-- Detecting CXX compiler ABI info
release|armeabi-v7a :-- Detecting CXX compiler ABI info - done
release|armeabi-v7a :-- Detecting CXX compile features
release|armeabi-v7a :-- Detecting CXX compile features - done
release|armeabi-v7a :-- Configuring done
release|armeabi-v7a :-- Generating done
release|armeabi-v7a :-- Build files have been written to: /builds/sebasira/android-module-boilerplate/app/.cxx/cmake/release/armeabi-v7a
release|arm64-v8a :-- Check for working C compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
release|arm64-v8a :-- Check for working C compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
release|arm64-v8a :-- Detecting C compiler ABI info
release|arm64-v8a :-- Detecting C compiler ABI info - done
release|arm64-v8a :-- Detecting C compile features
release|arm64-v8a :-- Detecting C compile features - done
release|arm64-v8a :-- Check for working CXX compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
release|arm64-v8a :-- Check for working CXX compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
release|arm64-v8a :-- Detecting CXX compiler ABI info
release|arm64-v8a :-- Detecting CXX compiler ABI info - done
release|arm64-v8a :-- Detecting CXX compile features
release|arm64-v8a :-- Detecting CXX compile features - done
release|arm64-v8a :-- Configuring done
release|arm64-v8a :-- Generating done
release|arm64-v8a :-- Build files have been written to: /builds/sebasira/android-module-boilerplate/app/.cxx/cmake/release/arm64-v8a
release|x86 :-- Check for working C compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
release|x86 :-- Check for working C compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
release|x86 :-- Detecting C compiler ABI info
release|x86 :-- Detecting C compiler ABI info - done
release|x86 :-- Detecting C compile features
release|x86 :-- Detecting C compile features - done
release|x86 :-- Check for working CXX compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
release|x86 :-- Check for working CXX compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
release|x86 :-- Detecting CXX compiler ABI info
release|x86 :-- Detecting CXX compiler ABI info - done
release|x86 :-- Detecting CXX compile features
release|x86 :-- Detecting CXX compile features - done
release|x86 :-- Configuring done
release|x86 :-- Generating done
release|x86 :-- Build files have been written to: /builds/sebasira/android-module-boilerplate/app/.cxx/cmake/release/x86
release|x86_64 :-- Check for working C compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
release|x86_64 :-- Check for working C compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
release|x86_64 :-- Detecting C compiler ABI info
release|x86_64 :-- Detecting C compiler ABI info - done
release|x86_64 :-- Detecting C compile features
release|x86_64 :-- Detecting C compile features - done
release|x86_64 :-- Check for working CXX compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
release|x86_64 :-- Check for working CXX compiler: /sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
release|x86_64 :-- Detecting CXX compiler ABI info
release|x86_64 :-- Detecting CXX compiler ABI info - done
release|x86_64 :-- Detecting CXX compile features
release|x86_64 :-- Detecting CXX compile features - done
release|x86_64 :-- Configuring done
release|x86_64 :-- Generating done
release|x86_64 :-- Build files have been written to: /builds/sebasira/android-module-boilerplate/app/.cxx/cmake/release/x86_64

> Task :app:externalNativeBuildRelease
Build boilerplate-native-lib_armeabi-v7a
[1/2] Building CXX object CMakeFiles/boilerplate-native-lib.dir/native-lib.cpp.o
[2/2] Linking CXX shared library /builds/sebasira/android-module-boilerplate/app/build/intermediates/cmake/release/obj/armeabi-v7a/libboilerplate-native-lib.so
Build boilerplate-native-lib_arm64-v8a
[1/2] Building CXX object CMakeFiles/boilerplate-native-lib.dir/native-lib.cpp.o
[2/2] Linking CXX shared library /builds/sebasira/android-module-boilerplate/app/build/intermediates/cmake/release/obj/arm64-v8a/libboilerplate-native-lib.so
Build boilerplate-native-lib_x86
[1/2] Building CXX object CMakeFiles/boilerplate-native-lib.dir/native-lib.cpp.o
[2/2] Linking CXX shared library /builds/sebasira/android-module-boilerplate/app/build/intermediates/cmake/release/obj/x86/libboilerplate-native-lib.so
Build boilerplate-native-lib_x86_64
[1/2] Building CXX object CMakeFiles/boilerplate-native-lib.dir/native-lib.cpp.o
[2/2] Linking CXX shared library /builds/sebasira/android-module-boilerplate/app/build/intermediates/cmake/release/obj/x86_64/libboilerplate-native-lib.so

> Task :app:mergeReleaseJniLibFolders
> Task :app:mergeReleaseNativeLibs
> Task :app:stripReleaseDebugSymbols
> Task :app:transformNativeLibsWithSyncJniLibsForRelease
> Task :app:bundleReleaseAar
> Task :app:uploadArchives
> Task :app:artifactoryPublish
> Task :artifactoryPublish
> Task :extractModuleInfo
> Task :app:extractModuleInfo
[pool-3-thread-1] Deploying artifact: <here was the URL of my artifact, in artifactory>
[pool-3-thread-1] Deploying artifact:  <here was the URL of my artifact, in artifactory>
> Task :artifactoryDeploy

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.6.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 3m 4s
35 actionable tasks: 33 executed, 2 up-to-date
section_end:1603669575:build_script
section_start:1603669575:after_script
section_end:1603669577:after_script
section_start:1603669577:archive_cache
section_end:1603669578:archive_cache
section_start:1603669578:upload_artifacts_on_success
section_end:1603669580:upload_artifacts_on_success
Job succeeded


And when it's not deployed:

------------------------------------------------------------
Gradle 5.6.4
------------------------------------------------------------

Build time:   2019-11-01 20:42:00 UTC
Revision:     dd870424f9bd8e195d614dc14bb140f43c22da98

Kotlin:       1.3.41
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM:          11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OS:           Linux 4.4.0-190-generic amd64

$ curl -fL https://getcli.jfrog.io | sh # collapsed multi-line command
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   178  100   178    0     0    455      0 --:--:-- --:--:-- --:--:--   455

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  1344  100  1344    0     0   3147      0 --:--:-- --:--:-- --:--:--  187k
Downloading the latest version of JFrog CLI...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100 19.0M  100 19.0M    0     0  26.0M      0 --:--:-- --:--:-- --:--:-- 26.0M
[Info] Encrypting password...
Server ID: Default-Server
Url: <myArtifactoryURL>
User: <myArtifactoryUser>
Password: <myPass>
Default:  true

$ sed -i 's,GRADLE_REPO_KEY,'"$GRADLE_REPO_KEY"',g' configuration.yaml
$ ./jfrog rt gradle-config --use-wrapper=true --repo-resolve=$GRADLE_REPO_KEY --server-id-resolve=Default-Server --repo-deploy=$GRADLE_REPO_KEY --server-id-deploy=Default-Server # collapsed multi-line command
[Info] gradle build config successfully created.
[Info] Downloading bintray/jcenter/org/jfrog/buildinfo/build-info-extractor-gradle/4.18.0/build-info-extractor-gradle-4.18.0-uber.jar
[Info] Downloaded 1 artifact.
[Info] Running gradle command: ./gradlew --init-script /root/.jfrog/dependencies/gradle/4.18.0/gradle.init clean artifactoryPublish -b build.gradle
Downloading https://services.gradle.org/distributions/gradle-5.6.4-all.zip
.....................................................................................................................................
Unzipping /builds/sebasira/android-module-boilerplate/.gradle/wrapper/dists/gradle-5.6.4-all/ankdp27end7byghfw1q2sw75f/gradle-5.6.4-all.zip to /builds/sebasira/android-module-boilerplate/.gradle/wrapper/dists/gradle-5.6.4-all/ankdp27end7byghfw1q2sw75f
Set executable permissions for: /builds/sebasira/android-module-boilerplate/.gradle/wrapper/dists/gradle-5.6.4-all/ankdp27end7byghfw1q2sw75f/gradle-5.6.4/bin/gradle
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/5.6.4/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
> Task :clean UP-TO-DATE

> Task :app:externalNativeBuildCleanDebug
Compatible side by side NDK version was not found for android.ndkVersion '21.3.6528147'
Checking the license for package NDK (Side by side) 21.3.6528147 in /sdk/licenses
License for package NDK (Side by side) 21.3.6528147 accepted.
Preparing "Install NDK (Side by side) 21.3.6528147 (revision: 21.3.6528147)".
"Install NDK (Side by side) 21.3.6528147 (revision: 21.3.6528147)" ready.
Installing NDK (Side by side) 21.3.6528147 in /sdk/ndk/21.3.6528147
"Install NDK (Side by side) 21.3.6528147 (revision: 21.3.6528147)" complete.
"Install NDK (Side by side) 21.3.6528147 (revision: 21.3.6528147)" finished.
Checking the license for package CMake 3.6.4111459 in /sdk/licenses
License for package CMake 3.6.4111459 accepted.
Preparing "Install CMake 3.6.4111459 (revision: 3.6.4111459)".
"Install CMake 3.6.4111459 (revision: 3.6.4111459)" ready.
Installing CMake 3.6.4111459 in /sdk/cmake/3.6.4111459
"Install CMake 3.6.4111459 (revision: 3.6.4111459)" complete.
"Install CMake 3.6.4111459 (revision: 3.6.4111459)" finished.

> Task :app:externalNativeBuildCleanRelease
> Task :app:clean UP-TO-DATE
> Task :app:artifactoryPublish
> Task :artifactoryPublish
> Task :extractModuleInfo
> Task :app:extractModuleInfo
> Task :artifactoryDeploy

BUILD SUCCESSFUL in 2m 53s
9 actionable tasks: 7 executed, 2 up-to-date
section_end:1604009769:build_script
section_start:1604009769:after_script
section_end:1604009771:after_script
section_start:1604009771:archive_cache
section_end:1604009772:archive_cache
section_start:1604009772:upload_artifacts_on_success
section_end:1604009774:upload_artifacts_on_success
Job succeeded


Versions

Additional context You will notice it uses Gradle v5.6.4. I've also update it to Gradle v6.7 with the same result, and the went back to v5.6.4 because was the last that suceed.

One thing I've notice from the below logs is that the jfrog-cli download size is different and that's what lead me to think that this happens on the latest version.

I try to set a previous version when downloading but it gives me another error:

[32;1m$ curl -fL https://getcli.jfrog.io | sh -s v1.39.7 # collapsed multi-line command
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   178  100   178    0     0    552      0 --:--:-- --:--:-- --:--:--   552

100  1344  100  1344    0     0   3622      0 --:--:-- --:--:-- --:--:--  3622
Downloading version v1.39.7 of JFrog CLI...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    85  100    85    0     0    129      0 --:--:-- --:--:-- --:--:--   128
./jfrog: line 1: {message:Could not find artifact with path 'v1.39.7/jfrog-cli-linux-amd64/jfrog'}: No such file or directory
section_end:1604010794:build_script
section_start:1604010794:after_script
section_end:1604010795:after_script
section_start:1604010795:upload_artifacts_on_failure
section_end:1604010797:upload_artifacts_on_failure
ERROR: Job failed: exit code 1

Maybe I'm just miss-using the cli with this new version, if that's the case, can you guide me?

Thanks in advance!

sebasira commented 4 years ago

I can confirm that this only happens to Android Libraries (that produces .aar artifacts). I've tested with 3 different modules and all of them behave the same way. Two of them had not changed since the last successful deploy and when trying to upload a dummy verison (with only changing the version and nothing else, just to test the deployment) they were not deployed.

Also test a Java library and was successfully deployed to the same Artifactory server with the same GitLab CI/CD script.

sebasira commented 4 years ago

Taking a closer look into the logs I've posted, I've notice that JFrog Gradle plugin (for Build Info extraction and Artifactory publishing) has also change and has been updated 3 days ago.

When artifacts are not deployed (maybe I should say generated, becuase I think they are not even generated and that why they are not deployed)

[Info] gradle build config successfully created.
[Info] Downloading bintray/jcenter/org/jfrog/buildinfo/build-info-extractor-gradle/4.18.0/build-info-extractor-gradle-4.18.0-uber.jar
[Info] Downloaded 1 artifact.
[Info] Running gradle command: ./gradlew --init-script /root/.jfrog/dependencies/gradle/4.18.0/gradle.init clean artifactoryPublish -b build.gradle

And when it was working:

Info] gradle build config successfully created.
[Info] Downloading bintray/jcenter/org/jfrog/buildinfo/build-info-extractor-gradle/4.15.2/build-info-extractor-gradle-4.15.2-uber.jar
[Info] Downloaded 1 artifact.
[Info] Running gradle command: ./gradlew --init-script /root/.jfrog/dependencies/gradle/4.15.2/gradle.init clean artifactoryPublish -b build.gradle
yahavi commented 4 years ago

Thanks for reporting this issue, @sebasira You diagnostic is correct. We did update the Gradle extractor version in the latest JFrog CLI release. Apologize for this issue. The last Gradle plugin releases includes many bug fixes and new features and we think it should be in the latest JFrog CLI. As a workaround you can use JFrog CLI 1.39.7 for now.

To speed up the fix, I created https://github.com/jfrog/build-info/pull/407. However in order to make sure all cases have been covered, we would appreciate additional information from you:

  1. In your build.gradle file, do you apply explicitly the Gradle Artifactory plugin? (apply plugin: 'com.jfrog.artifactory')
  2. How do you mention your published artifacts in the build.gradle? Do you specify the publications you wish to publish , for example:
    publishing {
    publications {
    app(MavenPublication) {
       groupId = group
       artifactId = project.getName()
       version = currentVersion
       artifact("$buildDir/outputs/apk/release/app-release-unsigned.apk")
     }
    }
    }
  3. If you can, creating a minimal reproducible example will help a lot.

Thanks in advance.

sebasira commented 4 years ago

@yahavi thank you for looking into this and for publishing a PR.

I'l answer your questions with the same number.

1- No. I 'm actually not using the Artifactory Gradle Plugin in my build.gradle. I relay in the jFrog CLI and GitLab CI/CD Pipeline to deploy. The jFrog CLI command uses the artifactory gradle. This is part of the YAML script from the first post where I use jFrog CLI

  ./jfrog rt gradle-config --use-wrapper=true --repo-resolve=$GRADLE_REPO_KEY --server-id-resolve=Default-Server --repo-deploy=$GRADLE_REPO_KEY --server-id-deploy=Default-Server
  ./jfrog rt gradle clean artifactoryPublish -b build.gradle --build-name=$ARTIFACT_NAME --build-number=$CI_JOB_ID

My build.gradle file knows nothing about the Artifactory Gradle Plugin. Here it's a simplify version of it:

apply plugin: 'com.android.library'

// This is what ArtifactoyyPublish task (in GitLab CI/CD Pipeline) uses to determine the PATH and VERSION of the uploaded artifact
group = 'ar.com.sebasira'
version = '6.3.7'

project.archivesBaseName = rootProject.name

android {

    compileSdkVersion 29
    defaultConfig {
        minSdkVersion 29
        targetSdkVersion 29
        versionName project.version
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        vectorDrawables {
            useSupportLibrary true
        }

        externalNativeBuild {
            cmake {
                cppFlags "-frtti -fexceptions"
            }
        }
    }

    buildTypes {
        debug {
            minifyEnabled false
        }

        release {
            minifyEnabled false
            consumerProguardFiles 'proguard-my-lib-rules.pro'
        }
    }

    libraryVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "${rootProject.name}-${defaultConfig.versionName}.aar"
        }
    }

    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
        }
    }
}

repositories {
    maven {
        url '<my-artifactory-repo>'
    }
}

dependencies {
    // All dependencies goes here
}

2- I think the answer to this question is also in the above answer. Look at this part of my build-gradle

 libraryVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "${rootProject.name}-${defaultConfig.versionName}.aar"
        }
    }

I also have in settings.gradle

include ':app'
rootProject.name='my-cool-library'

With this info (and the versions from the first lines of the build.gradle file) it will generate an artifact with this name:

my-cool-library-6.3.7.aar

And this line from the build.gradle file was very important for the naming (I don't remember exavtly why, but I got issues without it):

project.archivesBaseName = rootProject.name

And this is my full GitLab CI/CD YAML script (with only the deploy stage):

image: jangrewe/gitlab-ci-android

before_script:
  - export GRADLE_USER_HOME=$(pwd)/.gradle
  - chmod +x ./gradlew

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .gradle/

variables:
  GRADLE_VERSION: "6.7"
  ARTIFACT_NAME: "my-cool-library"
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"

stages:
  - deploy

.connect_artifactory: &connect_artifactory |
  curl -fL https://getcli.jfrog.io | sh
  ./jfrog rt config --url=$ARTIFACTORY_URL --user=$ARTIFACTORY_USER --password=$ARTIFACTORY_PASS
  ./jfrog rt c show

.upload_artifact: &upload_artifact |
  ./jfrog rt gradle-config --use-wrapper=true --repo-resolve=$GRADLE_REPO_KEY --server-id-resolve=Default-Server --repo-deploy=$GRADLE_REPO_KEY --server-id-deploy=Default-Server
  ./jfrog rt gradle clean artifactoryPublish -b build.gradle --build-name=$ARTIFACT_NAME --build-number=$CI_JOB_ID

.install_gradle: &install_gradle |
  curl -L https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-all.zip -o gradle.zip
  unzip -q gradle.zip
  export GRADLE_HOME=$(pwd)/gradle-$GRADLE_VERSION
  export PATH=${GRADLE_HOME}/bin:${PATH}
  echo $GRADLE_HOME
  echo $PATH
  gradle -v

publish:
  stage: deploy
  cache: {}
  script:
    # Download and Install Gradle
    - *install_gradle
    # Connect to JFrog Artifactory
    - *connect_artifactory
    # Replace the repository name in the configuration.yml to the correct one.
    - sed -i 's,GRADLE_REPO_KEY,'"$GRADLE_REPO_KEY"',g' configuration.yaml
    # Upload artifact to JFrog Artifactory
    - *upload_artifact

Notice that there is a variable name $ARTIFACT_NAME that MUST have the same name that my rootProject.name

3- About the minimal example, I would love to. The only problem is that my setup is very tight to my private GitLab Server and also a private Artifactory Server. I can create a dummy Android Library but I would need a public GitLab repo to post it wher eI can configure the CI/CD to deploy to a public Artifactory Server.

And finally, you said:

As a workaround you can use JFrog CLI 1.39.7 for now.

How can achieve that? I've try this:

 curl -fL https://getcli.jfrog.io | sh -s v1.39.7

but it will give me this output:

[32;1m$ curl -fL https://getcli.jfrog.io | sh -s v1.39.7 # collapsed multi-line command
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   178  100   178    0     0    552      0 --:--:-- --:--:-- --:--:--   552

100  1344  100  1344    0     0   3622      0 --:--:-- --:--:-- --:--:--  3622
Downloading version v1.39.7 of JFrog CLI...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    85  100    85    0     0    129      0 --:--:-- --:--:-- --:--:--   128
./jfrog: line 1: {message:Could not find artifact with path 'v1.39.7/jfrog-cli-linux-amd64/jfrog'}: No such file or directory
section_end:1604010794:build_script
section_start:1604010794:after_script
section_end:1604010795:after_script
section_start:1604010795:upload_artifacts_on_failure
section_end:1604010797:upload_artifacts_on_failure
ERROR: Job failed: exit code 1


This is the relevant part:

./jfrog: line 1: {message:Could not find artifact with path 'v1.39.7/jfrog-cli-linux-amd64/jfrog'}: No such file or directory

I also try with all other versions, even in my local computer and have the same error when I run the curl command in the terminal. It seems like there are no binaries for older versions just the latest one

yahavi commented 4 years ago

@sebasira You can find all available CLI versions in Bintray: https://bintray.com/jfrog/jfrog-cli-go. For example, here is the link for Linux amd64: https://bintray.com/jfrog/jfrog-cli-go/download_file?file_path=1.39.7%2Fjfrog-cli-linux-amd64%2Fjfrog

sebasira commented 4 years ago

Thank you! I can now deploy library updates with the older version of the jFrog CLI. I'll put the workaround here in case anyone stumble upon this:

In my previous GitLab CI/CD YAML script need to make the change in the .connect_artifactory sub-script. Replace:

  curl -fL https://getcli.jfrog.io | sh

with this:

  curl -L https://bintray.com/jfrog/jfrog-cli-go/download_file?file_path=1.39.7%2Fjfrog-cli-linux-amd64%2Fjfrog --output jfrog
  chmod +x jfrog

Notice that the URL points to the linux-amd64 distribution, change that url according to your OS.

I'll keep waiting for the official fix. Thank you!

yahavi commented 4 years ago

@sebasira after a deeper look at your curl command, I managed to download version 1.39.7 of the CLI with the getCli:

curl -fL https://getcli.jfrog.io | sh -s 1.39.7

I just removed the v before the version.

By the way - using the getCli is the preferred way since it automatically detects the operating system and it is more resilient to changes.

We will seriously investigate and will search for "out of the box" solution for Android users. We will also keep you updated here.

sebasira commented 4 years ago

Thank you very much!

I also think the best way is using getCLI script. I'll update my scripts.

If I can be of any assistance to test for Android libraries, it would be my pleasure.

About the Android sample project to reproduce this, I was thinking that the GitLab repo is not needed. I can create a sample Android project, with a bash script (emulating the YAML script of GitLab) and it should be working in the same way. You would only need to change some variables to point to your Artifactory server URL with your credentials.

yahavi commented 4 years ago

Thanks, @sebasira A minimal sample Android project would be appreciated. Most interesting are the build.gradle file and the information on what do you expects to be uploaded by default (apk? aar?). If you want to contribute code, you can upload the sample here: https://github.com/jfrog/project-examples/tree/master/gradle-examples as gradle-android-example-ci-server by creating a pull request. Otherwise, a simple GitHub repository will do.

sebasira commented 3 years ago

Hi!

It's been a long time... I've created a sample library so that you guys can work with it and I submit it as a PR.

I'd like to remark that the extension of the artifact is .aar, and you can find in the build.gradle file how I rename the artifact to the name I want. I'm guessing the extension is the issue.

I'm here again with this issue because I was using a previous version of jFrog CLI but now I can no longer use it because it seems that it uses an old artifact that's no longer available:

[Info] gradle build config successfully created.
[Info] Downloading bintray/jcenter/org/jfrog/buildinfo/build-info-extractor-gradle/4.15.2/build-info-extractor-gradle-4.15.2-uber.jar
[Error] 403 Forbidden 
ERROR: Job failed: exit code 1
sebasira commented 3 years ago

For what is worth, I have more information after adding INFO logging level to the script:

> Task :app:assembleRelease
Skipping task ':app:assembleRelease' as it has no actions.
:app:assembleRelease (Thread[Daemon worker,5,main]) completed. Took 0.001 secs.
:app:artifactoryPublish (Thread[Daemon worker,5,main]) started.
> Task :app:artifactoryPublish
Caching disabled for task ':app:artifactoryPublish' because:
  Build cache is disabled
Task ':app:artifactoryPublish' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
:app:artifactoryPublish (Thread[Daemon worker,5,main]) completed. Took 0.003 secs.
:artifactoryPublish (Thread[Daemon worker,5,main]) started.
> Task :artifactoryPublish
Caching disabled for task ':artifactoryPublish' because:
  Build cache is disabled
Task ':artifactoryPublish' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
:artifactoryPublish (Thread[Daemon worker,5,main]) completed. Took 0.003 secs.
:extractModuleInfo (Thread[Daemon worker,5,main]) started.
> Task :extractModuleInfo
Caching disabled for task ':extractModuleInfo' because:
  Build cache is disabled
Task ':extractModuleInfo' is not up-to-date because:
  Task.upToDateWhen is false.
:extractModuleInfo (Thread[Daemon worker,5,main]) completed. Took 0.546 secs.
:app:extractModuleInfo (Thread[Daemon worker,5,main]) started.
> Task :app:extractModuleInfo
Caching disabled for task ':app:extractModuleInfo' because:
  Build cache is disabled
Task ':app:extractModuleInfo' is not up-to-date because:
  Task.upToDateWhen is false.
Artifacts for configuration 'androidTestAnnotationProcessor' were not all resolved, skipping
Artifacts for configuration 'androidTestApi' were not all resolved, skipping
Artifacts for configuration 'androidTestCompile' were not all resolved, skipping
Artifacts for configuration 'androidTestCompileOnly' were not all resolved, skipping
Artifacts for configuration 'androidTestDebugAnnotationProcessor' were not all resolved, skipping
Artifacts for configuration 'androidTestDebugApi' were not all resolved, skipping
Artifacts for configuration 'androidTestDebugCompile' were not all resolved, skipping
Artifacts for configuration 'androidTestDebugCompileOnly' were not all resolved, skipping
Artifacts for configuration 'androidTestDebugImplementation' were not all resolved, skipping
Artifacts for configuration 'androidTestDebugProvided' were not all resolved, skipping
Artifacts for configuration 'androidTestDebugPublish' were not all resolved, skipping
Artifacts for configuration 'androidTestDebugRuntimeOnly' were not all resolved, skipping
Artifacts for configuration 'androidTestDebugWearApp' were not all resolved, skipping
Artifacts for configuration 'androidTestImplementation' were not all resolved, skipping
Artifacts for configuration 'androidTestProvided' were not all resolved, skipping
Artifacts for configuration 'androidTestPublish' were not all resolved, skipping
Artifacts for configuration 'androidTestReleaseAnnotationProcessor' were not all resolved, skipping
Artifacts for configuration 'androidTestReleaseApi' were not all resolved, skipping
Artifacts for configuration 'androidTestReleaseCompile' were not all resolved, skipping
Artifacts for configuration 'androidTestReleaseCompileOnly' were not all resolved, skipping
Artifacts for configuration 'androidTestReleaseImplementation' were not all resolved, skipping
Artifacts for configuration 'androidTestReleaseProvided' were not all resolved, skipping
Artifacts for configuration 'androidTestReleasePublish' were not all resolved, skipping
Artifacts for configuration 'androidTestReleaseRuntimeOnly' were not all resolved, skipping
Artifacts for configuration 'androidTestReleaseWearApp' were not all resolved, skipping
Artifacts for configuration 'androidTestRuntimeOnly' were not all resolved, skipping
Artifacts for configuration 'androidTestUtil' were not all resolved, skipping
Artifacts for configuration 'androidTestWearApp' were not all resolved, skipping
Artifacts for configuration 'annotationProcessor' were not all resolved, skipping
Artifacts for configuration 'api' were not all resolved, skipping
Artifacts for configuration 'archives' were not all resolved, skipping
Artifacts for configuration 'compile' were not all resolved, skipping
Artifacts for configuration 'compileOnly' were not all resolved, skipping
Artifacts for configuration 'coreLibraryDesugaring' were not all resolved, skipping
Artifacts for configuration 'debugAllApiPublication' were not all resolved, skipping
Artifacts for configuration 'debugAllRuntimePublication' were not all resolved, skipping
Artifacts for configuration 'debugAndroidTestAnnotationProcessorClasspath' were not all resolved, skipping
Artifacts for configuration 'debugAndroidTestCompileClasspath' were not all resolved, skipping
Artifacts for configuration 'debugAndroidTestRuntimeClasspath' were not all resolved, skipping
Artifacts for configuration 'debugAnnotationProcessor' were not all resolved, skipping
Artifacts for configuration 'debugAnnotationProcessorClasspath' were not all resolved, skipping
Artifacts for configuration 'debugApi' were not all resolved, skipping
Artifacts for configuration 'debugApiElements' were not all resolved, skipping
Artifacts for configuration 'debugApiPublication' were not all resolved, skipping
Artifacts for configuration 'debugCompile' were not all resolved, skipping
Artifacts for configuration 'debugCompileClasspath' were not all resolved, skipping
Artifacts for configuration 'debugCompileOnly' were not all resolved, skipping
Artifacts for configuration 'debugImplementation' were not all resolved, skipping
Artifacts for configuration 'debugProvided' were not all resolved, skipping
Artifacts for configuration 'debugPublish' were not all resolved, skipping
Artifacts for configuration 'debugRuntimeClasspath' were not all resolved, skipping
Artifacts for configuration 'debugRuntimeElements' were not all resolved, skipping
Artifacts for configuration 'debugRuntimeOnly' were not all resolved, skipping
Artifacts for configuration 'debugRuntimePublication' were not all resolved, skipping
Artifacts for configuration 'debugUnitTestAnnotationProcessorClasspath' were not all resolved, skipping
Artifacts for configuration 'debugUnitTestCompileClasspath' were not all resolved, skipping
Artifacts for configuration 'debugUnitTestRuntimeClasspath' were not all resolved, skipping
Artifacts for configuration 'debugWearApp' were not all resolved, skipping
Artifacts for configuration 'default' were not all resolved, skipping
Artifacts for configuration 'implementation' were not all resolved, skipping
Artifacts for configuration 'jacocoAgent' were not all resolved, skipping
Artifacts for configuration 'jacocoAnt' were not all resolved, skipping
Artifacts for configuration 'lintChecks' were not all resolved, skipping
Artifacts for configuration 'provided' were not all resolved, skipping
Artifacts for configuration 'publish' were not all resolved, skipping
Artifacts for configuration 'releaseAllApiPublication' were not all resolved, skipping
Artifacts for configuration 'releaseAllRuntimePublication' were not all resolved, skipping
Artifacts for configuration 'releaseAnnotationProcessor' were not all resolved, skipping
Artifacts for configuration 'releaseApi' were not all resolved, skipping
Artifacts for configuration 'releaseApiElements' were not all resolved, skipping
Artifacts for configuration 'releaseApiPublication' were not all resolved, skipping
Artifacts for configuration 'releaseCompile' were not all resolved, skipping
Artifacts for configuration 'releaseCompileOnly' were not all resolved, skipping
Artifacts for configuration 'releaseImplementation' were not all resolved, skipping
Artifacts for configuration 'releaseProvided' were not all resolved, skipping
Artifacts for configuration 'releasePublish' were not all resolved, skipping
Artifacts for configuration 'releaseRuntimeElements' were not all resolved, skipping
Artifacts for configuration 'releaseRuntimeOnly' were not all resolved, skipping
Artifacts for configuration 'releaseRuntimePublication' were not all resolved, skipping
Artifacts for configuration 'releaseUnitTestAnnotationProcessorClasspath' were not all resolved, skipping
Artifacts for configuration 'releaseUnitTestCompileClasspath' were not all resolved, skipping
Artifacts for configuration 'releaseUnitTestRuntimeClasspath' were not all resolved, skipping
Artifacts for configuration 'releaseWearApp' were not all resolved, skipping
Artifacts for configuration 'runtimeOnly' were not all resolved, skipping
Artifacts for configuration 'testAnnotationProcessor' were not all resolved, skipping
Artifacts for configuration 'testApi' were not all resolved, skipping
Artifacts for configuration 'testCompile' were not all resolved, skipping
Artifacts for configuration 'testCompileOnly' were not all resolved, skipping
Artifacts for configuration 'testDebugAnnotationProcessor' were not all resolved, skipping
Artifacts for configuration 'testDebugApi' were not all resolved, skipping
Artifacts for configuration 'testDebugCompile' were not all resolved, skipping
Artifacts for configuration 'testDebugCompileOnly' were not all resolved, skipping
Artifacts for configuration 'testDebugImplementation' were not all resolved, skipping
Artifacts for configuration 'testDebugProvided' were not all resolved, skipping
Artifacts for configuration 'testDebugPublish' were not all resolved, skipping
Artifacts for configuration 'testDebugRuntimeOnly' were not all resolved, skipping
Artifacts for configuration 'testDebugWearApp' were not all resolved, skipping
Artifacts for configuration 'testImplementation' were not all resolved, skipping
Artifacts for configuration 'testProvided' were not all resolved, skipping
Artifacts for configuration 'testPublish' were not all resolved, skipping
Artifacts for configuration 'testReleaseAnnotationProcessor' were not all resolved, skipping
Artifacts for configuration 'testReleaseApi' were not all resolved, skipping
Artifacts for configuration 'testReleaseCompile' were not all resolved, skipping
Artifacts for configuration 'testReleaseCompileOnly' were not all resolved, skipping
Artifacts for configuration 'testReleaseImplementation' were not all resolved, skipping
Artifacts for configuration 'testReleaseProvided' were not all resolved, skipping
Artifacts for configuration 'testReleasePublish' were not all resolved, skipping
Artifacts for configuration 'testReleaseRuntimeOnly' were not all resolved, skipping
Artifacts for configuration 'testReleaseWearApp' were not all resolved, skipping
Artifacts for configuration 'testRuntimeOnly' were not all resolved, skipping
Artifacts for configuration 'testWearApp' were not all resolved, skipping
Artifacts for configuration 'wearApp' were not all resolved, skipping
:app:extractModuleInfo (Thread[Daemon worker,5,main]) completed. Took 2.012 secs.
:artifactoryDeploy (Thread[Daemon worker,5,main]) started.
> Task :artifactoryDeploy
Caching disabled for task ':artifactoryDeploy' because:
  Build cache is disabled
Task ':artifactoryDeploy' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
:artifactoryDeploy (Thread[Daemon worker,5,main]) completed. Took 0.211 secs.
AAPT2 aapt2-4.2.1-7147631-linux Daemon #0: shutdown
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 4m 13s
35 actionable tasks: 33 executed, 2 up-to-date
Job succeeded
yahavi commented 3 years ago

@sebasira, Thanks for the reproducer! We will look into it and hopefully will fix this issue soon.

yahavi commented 3 years ago

@sebasira, The JFrog CLI uses the maven-publish plugin to collect the publications in order to upload them to Artifactory. I followed this guide to configure publications on Android: https://developer.android.com/studio/build/maven-publish-plugin To make the reproducer work, you should define the requested publications.

I manage to publish test-library-name-1.1s.aar using the following steps:

  1. Add the maven-publish plugin at the top of the file.
  2. Add the following afterEvaluate clause:
    afterEvaluate {
    publishing {
        publications {
            // Creates a Maven publication called "release".
            release(MavenPublication) {
                // Applies the component for the release build variant.
                from components.release
                artifactId = "${rootProject.name}"
                version = "${android.defaultConfig.versionName}"
            }
        }
    }
    // Add the new "release" publication to the list of publications to publish:
    artifactoryPublish {
        publications(publishing.publications.release)
    }
    }
  3. To make it work on my machine, I had to delete the applicationId "com.example.testlibrary". I'm not sure why but I got the following exception: Library projects cannot set applicationId.

Results:

➜ gradle-android-library-example-ci-server git:(master) ✗ jfrog rt gradle clean aP [Info] Running gradle command: ./gradlew --init-script /Users/yahavi/.jfrog/dependencies/gradle/4.24.12/gradle.init clean aP [pool-9-thread-1] Deploying artifact: http://127.0.0.1:8081/artifactory/libs-release-local/test-library-name/test-library-name/1.1s/test-library-name-1.1s.aar [pool-9-thread-1] Deploying artifact: http://127.0.0.1:8081/artifactory/libs-release-local/test-library-name/test-library-name/1.1s/test-library-name-1.1s.module

Please let me know if that helped.

sebasira commented 3 years ago

Thank you!

Yes this resolves the issue! You can close it if you like. I did not do it just in case you need or what additional information

sebasira commented 3 years ago

About the applicationId that was my bad! It's correct libraries can not set the applicationId. Only applications can set the applicationId

sebasira commented 3 years ago

I'm sorry... I have a new issue right now with this setup.

The problem is that I've got 2 stages on my CI configuration: test and deploy.

To speed up trial-and-error tests I was making, I've remove the test stage. And when I re-add it I've got an error in the test stage saying that:

Could not find method artifactoryPublish() for arguments [build_65alhtgfhtvsukhk0xe6ip8kl$_run_closure2$_closure18@48b7f5f3] on project ':app' of type org.gradle.api.Project.

I'm guessing that's because in my original configuration I was not using the Artifactory Gradle Plugin and making the deployment via CI/CD. And in the test stage I do not have anything related to Artifactory.

Is there any way to solve this issue from the CI script and not using the gradle plugin?

I mean, the proposed changes are relaying on changes at the build.gradle file. I would like not to do so and just relay on the CI config file.

Till now I've been using jFrog CLI v1.39.7 and it's still working fine with the current configuration. So if it was (and still is) possible without the Gradle Plugin, I was hoping in keeping it that way.

Could it be possible to apply the same instructions/configuration provided in the afterEvaluate via the CLI?

UPDATE

I've also realize I was missing the gitlab-ci.yml file in the submitted PR. I'm sorry about that! I'll add it right now!

UPDATE 2

To be more clear... if I understand correctly, if put the deployment in the build.gradle after each build the artifacts will be deployed. Even when in my local machine, I guess, right?

I only want to upload the artifacts in the CI Server (GitLab) if tests passes and everything is correct. So I would like not to have anything related to Artifactory in the build.gradle file. I'm using the same setup to deploy .jar (other Java libraries) and it works without a problem. But since version 1.40.0 the .aar files stop being deployed. It's like they are not found because they have another extension...

yahavi commented 3 years ago

@sebasira, First, just to make sure that we are aligned, The JFrog CLI uses the Gradle Artifactory plugin to resolve dependencies and publish artifacts to Artifactory.

I think I can make it worked like in 1.39.7, but please note that this method is deprecated from the Gradle side, and may break in the future. Until this version, we used the old Gradle publish-configurations method, e.g. we extract the archives collected by the default archive configuration. You can read more about this method here. Therefore we recommend you to define publications as instructed in the official Android guide: https://developer.android.com/studio/build/maven-publish-plugin

You can make it work using one of the 3 options:

  1. Always run Gradle with the JFrog CLI:

    jfrog rt gradle clean aP
    jfrog rt gradle clean test
  2. Always apply the Artifactory plugin: Add this at the top of your build.gradle:

    
    buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
    }
    }

apply plugin: 'com.jfrog.artifactory'

Also, run `jfrog rt gradle-config ...` with `--uses-plugin` flag.

3. Optionally run the artifactoryPublish by wrapping it with `pluginManager.withPlugin('com.jfrog.artifactory')`:
```groovy
pluginManager.withPlugin('com.jfrog.artifactory') {
    artifactoryPublish {
        publications(publishing.publications.release)
    }
}

Please let me know if that helped.

sebasira commented 3 years ago

@yahavi thank you again!

Please excuse me, after re-reading my latest comment it was really a mess... That's because my head is a mess and sometimes I do not find the right words to express my self. I will try to make it as clear as I can.

Yes, I know jFrog CLI uses the Artifactory Gradle plugin. What I would like to avoid is to have any artifactory configuration in the build.gradle file. I would like that anything related to that will be present in the gitlab-ci.yml file. As it is today. Maybe with .aar files that's not possible and that's the whole center of the discussion.

If I'm following the conversation right, that's not possible and the afterEvaluate block is recommended/mandatory for .aar files. Am I right?

I don't have knowledge on groovy so I understand only a little about your suggestions. I think the one I like the most is the 3rd. Because what I understand is that it will only call the artifactoryPublish if the artifactory plugin is present, and that condition will only be met when at the deploy stage. Is that correct? I've try it and now all stages passes and artifacts are deployed.

yahavi commented 3 years ago

@sebasira, Your input helps us to learn and to keep improving. Thanks again!

You are right. Currently, there is no option to publish Android variants without publication and the Artifactory configuration in the build.gradle file. However, that doesn't mean that in the future there wouldn't be such options. The goal is to make these kinds of builds as simple as possible.

I'm glad to hear that the 3rd option worked for you.

it will only call the artifactoryPublish if the artifactory plugin is present, and that condition will only be met when at the deploy stage. Is that correct?

That's correct.

Please let us know if there are any more difficulties.

sebasira commented 3 years ago

It's a pleasure!

Thank all of you for this tool that allows me to work and keep my dependencies available from a central repo!

If you ever need any help regarding Android in the future, I'll be glad to help.

Feel free to close this issue... I didn't what to do it my self because I believe you should take that decision.