how does one closeAndRelease Nexus repository with...
# gradle
a
how does one closeAndRelease Nexus repository with gradle consistently?
io.codearte.nexus-staging
is so flaky. i get timeouts which hinders Continuous Delivery a lot
v
Never had problems with it. If it is flaky maybe it is more a problem of the Nexus you want to publish to?
a
Can I maybe take a peek at your gradle configurations? Perhaps I am missing something. The errors something about expecting one repo and finding five
But again, sometimes it does pass. When it fails, it asks me to to increase the number of attempts from 65. Which is already too much if you ask me
v
That sounds like you try to publish from TravisCI, could that be?
a
I am publishing from github actions. Is that a problem?
Here is the latest error message
Copy code
DEPRECATION WARNING. The staging repository ID is not provided. The fallback mode may impact release reliability and is deprecated. Please consult the project FAQ how it can be fixed.
Attempt 61/61 failed. WrongNumberOfRepositories was thrown with message 'Wrong number of received repositories in state 'open'. Expected 1, received 3'. Giving up. Configure longer timeout if necessary.
v
Do you want the short solution or the long explanation?
a
Long would be sufficient. Thank you in advance
v
Ok then.
io.codearte.nexus-staging
can operate in two ways when closing a repository. Either "you" told it the id of the repository it should close, or if not then it queries all open repositories and expects to find exactly one. If it finds not exactly one (0 or more than one) it retries the configured amount of times and then fails if not found exactly one, as it cannot guess which one is the one it should close. This also means, that if there are unclosed repositories for example due to half-finished releases, future release tries will not succeed unless you log in and close or delete all open repositories. Why I asked about TravisCI is, because when releaseing from TravisCI there is a significant problem. Outgoing requests often have changing IPs. And when uploading files to Nexus without specifying a repository id, then it will group them by IP. Meaning if you upload all files from the same IP, they will end up in the same repository, but if you upload from changing IPs, multiple repositories are created and then the heuristic with one unclosed repository does not work. Thankfully there is another plugin that provides a solution which is called
de.marcphilipp.nexus-publish
and cooperates nicely with
io.codearte.nexus-staging
. It up-front explicitly creates a staging repository, configures the publishing repository with an URL with the explicit repository id so that all uploads land in the repository and if the
io.codearte.nexus-staging
plugin is also applied, then configures the staging repository id on its extensions, so that it exactly knows which repository to close and does not need any heuristics. Also you asked for an example where it works, so here you have it: https://github.com/Vampire/command-framework/blob/master/buildSrc/src/main/kotlin/net/kautler/publishing.gradle.kts
a
Thank you so much @Vampire, you are a life saver. I don't know if you have noticed, but you have been helping me a lot lately across multiple channels. I can't thank you enough, so thank you, thank you and thank you
v
You're welcome. I did notice. :-) Everytime I see your profile picture I have these guys in mind

https://i.ytimg.com/vi/WO1kLCb8K54/maxresdefault.jpgâ–¾

Don't take that personally please, it is a combination of the reflection in your glasses and the small size of the profile picture in normal messages. :-D
😅 1
a
Thanks