-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull dependencies from the instance-level registry, push to the project-level registry #22
Comments
After looking at the code, I tried it with
But I get the following exception:
Which looks weird to me, because it seems like it's trying to push to the instance level registry instead of the project level one |
Are you trying to publish from within gitlab ci or from your local machine? If you are trying to publish from within a gitlab ci job, so long as you have the proper permissions and are trying to publish to the project the CI job is running under the only thing you should need is to include the plugin. import com.gilcloud.sbt.gitlab.{GitlabCredentials,GitlabPlugin}
GitlabPlugin.autoImport.gitlabGroupId := Some(12345)
GitlabPlugin.autoImport.gitlabProjectId := Some(12345)
GitlabPlugin.autoImport.gitlabDomain := "my-gitlab-host.com"
GitlabPlugin.autoImport.gitlabCredentials := Some(GitlabCredentials("Private-Token","<API-KEY>"))
// Alternatively for credential management
// ideal for pulling artifacts locally and keeping tokens out of your source control
// see below for sample .credentials file
credentials += Credentials(Path.userHome / ".sbt" / ".credentials.gitlab"), either way you shouldn't need to set the Given the error message it looks like you might be using the |
@listba Thanks for the answer! I am trying to publish from within gitlab ci. I forgot to mention that I need to add an additional maven resolver for the dependencies (we have a proxy for maven central where we pull external dependencies). I don't use |
@L7R7 Did you manage to get that working with a normal mvn resolver like the one above?
I got the feeling that gitlab demands custom headers that this plugin works with but that means having to disable coursier? |
@hedefalk I'm not sure I understand your question. Pulling dependencies works "out of the box", with dependencies from Gitlab and our Nexus mirror. As soon as I want to publish, things break with the error message described above. Coursier is disabled, as described in the docs |
I think I might have found a solution now. At least I'm much closer now. I originally tried it in a multi-project build which is a bit more involved than it should. I tried it with a simple sbt project and now almost everything works out of the box, like @listba said above. I had to provide the resolver explicitly though (I'm ok with that). Now building and publishing works as expected, but only in the CI pipeline. It doesn't work locally. I tried what is described in the readme and in #21: I have a .credentials.gitlab file with a valid API Token (double checked it via curl) and the gitlab host ( I played around with a couple of possibilities and found out that it works when I invoke it like this: |
Would you be willing/able to share your build.sbt file in here? Hard to help without knowing what you are doing.
|
Sure, here's the ThisBuild / useCoursier := false
lazy val root = (project in file("."))
.settings(
name := "sbt-gitlab-test",
credentials += Credentials(Path.userHome / ".sbt" / ".credentials.gitlab"),
libraryDependencies ++= Vector(
"foo.bar" % "baz" % "1.2.3",
),
resolvers += ("gitlab-maven" at "https://my.gitlab.com/api/v4/packages/maven"),
resolvers += "nexus-mirror" at "https://nexus.foo.com",
) I tried to simplify the project as much as I can, so I have one dependency that comes from gitlab, the sbt-gitlab plugin is the only one that's enabled. My credentials file looks like this:
which looks good to me (I wasn't sure about the host field: Should I include |
Update: it works locally when I set: GitlabPlugin.autoImport.gitlabDomain := "my.gitlab.com" But with that, it fails in CI when publishing the package:
full stacktrace
|
Ah ok, so I think the problem lies here resolvers += ("gitlab-maven" at "https://my.gitlab.com/api/v4/packages/maven"), I don't know the internals of sbt very well, but the plugin uses tldr: try changing that to something unique like |
Oh, thank you very much! Your explanations totally make sense. Renaming the resolver works, at least for the simple project. I'll test it tomorrow with the actual one, but I'm pretty sure it will work. So the learning is that I have to set the gitlab domain explicitly. I can live with that, though. It's just one line and it won't ever change for my use cases. |
As expected, it works now also for proper "real world" projects. Thanks again for helping! |
I'd like to publish a library to Gitlab that has dependencies that must be pulled from the instance-level Gitlab repository.
Do I have to configure the publish/pull URLs separately? If so, how? Or is it enough to configure the instance-level registry as resolver?
The text was updated successfully, but these errors were encountered: