Skip to content

Commit

Permalink
Bug: gitlabProjectId was never used (#92)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Zolotko <oleksandr.zolotko@ibm.com>
  • Loading branch information
azolotko and Alex Zolotko committed Nov 30, 2023
1 parent 75a3cbb commit 25cc159
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ gitlabRepositories ++= Seq(
)
```

### Publishing to GitLab via GitLab CI/CD
### Publishing from GitLab CI/CD

Utilizing the sbt publish command within GitLab CI/CD should require no additional configuration. This plugin
automatically pulls the following GitLab environment variables which should always be provided by default within GitLab
Pipelines
Doing `sbt publish` from GitLab CI/CD should require no additional configuration.
This plugin automatically pulls the following GitLab environment variables provided by GitLab Pipelines:

```shell
$CI_JOB_TOKEN # Access Token to authorize read/writes to the GitLab package registry
Expand All @@ -70,6 +69,17 @@ $CI_GROUP_ID # GitLab Group ID. Used for fetching Artifacts published under t
$CI_SERVER_HOST # The host name for GitLab defaults to gitlab.com
```

### Publishing outside GitLab CI/CD

For `sbt publish` to work outside GitLab CI/CD, at least `gitlabDomain` and `gitlabProjectId` need to be defined:

```sbt
gitlabDomain := "gitlab.your-company.com"
gitlabProjectId := GitlabProjectId("unicorn").some
```

(remember to set up the [Credentials](#Credentials))

### Testing

Run `test` for regular unit tests (there are none at the moment).
Expand Down
14 changes: 5 additions & 9 deletions src/main/scala/nl/zolotko/sbt/gitlab/GitlabPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ object GitlabPlugin extends AutoPlugin {
)
}

private lazy val gitlabProjectSettings: Seq[Def.Setting[?]] = {
val gitlabProjectId = sys.env.get("CI_PROJECT_ID").map(GitlabProjectId.apply)

private lazy val gitlabProjectSettings: Seq[Def.Setting[?]] =
Seq(
publishMavenStyle := true,
gitlabDomain := sys.env.getOrElse("CI_SERVER_HOST", "gitlab.com"),
Expand All @@ -117,12 +115,11 @@ object GitlabPlugin extends AutoPlugin {
updateSbtClassifiers := updateSbtClassifiers
.dependsOn(gitlabHeaderAuthHandler)
.value,
publish := publish.dependsOn(gitlabHeaderAuthHandler).value,
publish := publish.dependsOn(gitlabHeaderAuthHandler).value,
gitlabProjectId := sys.env.get("CI_PROJECT_ID").map(GitlabProjectId.apply),
publishTo := (ThisProject / publishTo).value.orElse(
gitlabProjectId
.map(
GitlabProjectRepository(gitlabDomain.value, _).resolver
)
gitlabProjectId.value
.map(GitlabProjectRepository(gitlabDomain.value, _).resolver)
),
gitlabRepositories := Seq.empty,
resolvers ++= gitlabRepositories.value.map(_.resolver),
Expand All @@ -142,5 +139,4 @@ object GitlabPlugin extends AutoPlugin {
allGitlabCredentials.value
)
)
}
}

0 comments on commit 25cc159

Please sign in to comment.