bintray / gradle-bintray-plugin

Apache License 2.0
1.28k stars 197 forks source link

Don't fail if artifact already exists [error 409] #283

Open TomasValenta opened 5 years ago

TomasValenta commented 5 years ago

Hello,

we have multi module Android project. For uploading AAR artifacts to Bintray we using bintray-release plugin, which uses the gradle-bintray-plugin under the hood. We have configured our multi module project the same way as the new AndroidX library, so each module has an independent version. Our CI is building every module every time even if nothing changed

script:
    - ./gradlew clean assembleRelease bintrayUpload -PbintrayUser=$B_USER -PbintrayKey=$B_KEY

so we don't want the unchanged artifact to upload. Everything works fine, except upload to the Bintray repo.

Current behavior: Execution failed for task ':module-name:bintrayUpload'. Could not upload to 'https://api.bintray.com/content/.../version/com/sygic/maps/module-name/version/module-name-version-sources.jar': HTTP/1.1 409 Conflict [message:Unable to upload files: An artifact with the path 'com/sygic/maps/module-name/version/module-name-version-sources.jar' already exists]

Expected behavior:

bintray {
    ...
    skipUploadIfExist = true // new option
}

Then convert the error to "just" warning and continue without fail.

Note: As a workaround we currently using override = true, but it is not an ideal solution.

StefMa commented 5 years ago

To be honest I didn't find that very useful. I would rather think about why do you try to upload something when nothing have changed. I would update my pipeline so that I know 'nothing have changed, no need to upload'...

TomasValenta commented 5 years ago

Hello @StefMa,

let me explain it a little bit more. This is our CI configuration file and bintray-release plugin configuration file. The independent modules versions are defined in the Gradle project file. The deploy stage is triggered only when the new global project tag is pushed to the remote.

Actually, I can't imagine how to manage the case: 'nothing has changed, no need to upload' directly on the CI. Store somewhere the versions diff? Store and compare commits? The simplest way for us is: The version already exists on target? Ok, skip the upload.

For me personally, the "skipUploadIfExist" make more sense than the existing "override" attribute. Who wants to replace an already published version? This can be very tricky and dangerous for target consumers.

StefMa commented 5 years ago

What do you mean with

The deploy stage is triggered only when the new global project tag is pushed to the remote.

I assume that each new git tag is a new version, no? I mean you will only create a new tag if you change your version name, right? And even if nothing have changed (inside the module/code) the new version can be published.

TomasValenta commented 5 years ago

@StefMa The project is multi-module, the git tag defines the global version of the project (used internally for the sample app versioning, which promotes all the modules in the project). Each module has an independent version of the global project version. For example:

git tag 1.0.0 - defines the global project version used in the sample app (it will change with any change of any module)

app-samples - use the git tag version, so now 1.0.0

module-search-1.0.0 module-browsemap-1.0.0 module-common-1.0.0 uikit-viewmodels-1.0.0 uikit-views-1.0.0 ...

Now, for example, module-browsemap has changed to 1.1.0 and uikit-views to 1.0.1:

git tag 1.0.2

app-samples - 1.0.2 (used the git tag version)

module-search-1.0.0 - unchanged, this version already exist on target (bintray) module-browsemap-1.1.0 - defined independently module-common-1.0.0 - unchanged, this version already exist on target (bintray) uikit-viewmodels-1.0.0 - unchanged, this version already exist on target (bintray) uikit-views-1.0.1 - defined independently ...

Later, only the module-search has changed from 1.0.0 to 2.0.0:

git tag 1.1.0

app-samples - 1.1.0 (used the git tag version)

module-search-2.0.0 - defined independently module-browsemap-1.1.0 - unchanged, this version already exist on target (bintray) module-common-1.0.0 - unchanged, this version already exist on target (bintray) uikit-viewmodels-1.0.0 - unchanged, this version already exist on target (bintray) uikit-views-1.0.1 - unchanged, this version already exist on target (bintray) ...

New module added:

git tag 2.0.0

app-samples - 2.0.0 (used the git tag version)

module-navigation-1.0.0 - defined independently module-search-2.0.0 - unchanged, this version already exist on target (bintray) module-browsemap-1.1.0 - unchanged, this version already exist on target (bintray) module-common-1.0.0 - unchanged, this version already exist on target (bintray) uikit-viewmodels-1.0.0 - unchanged, this version already exist on target (bintray) uikit-views-1.0.1 - unchanged, this version already exist on target (bintray) ...

AndyGettingAn commented 3 years ago

Did you solve this problem? I am currently stuck on the same problem and don't like using the "override = true" option.

TomasValenta commented 3 years ago

Did you solve this problem? I am currently stuck on the same problem and don't like using the "override = true" option.

No 😞