Skip to content
Snippets Groups Projects
Verified Commit bd28ad9f authored by Jan-Niclas Strüwer's avatar Jan-Niclas Strüwer
Browse files

gitlab client setup and git wrapper

parent 869a1de0
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,8 @@ dependencies { ...@@ -28,7 +28,8 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.gitlab4j:gitlab4j-api:5.2.0") implementation("org.gitlab4j:gitlab4j-api:6.0.0-rc.1")
implementation("org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r")
developmentOnly("org.springframework.boot:spring-boot-devtools") developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("com.h2database:h2") runtimeOnly("com.h2database:h2")
testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.springframework.boot:spring-boot-starter-test")
......
...@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestBody ...@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController import org.springframework.web.bind.annotation.RestController
data class RepositoryChangedDto(val repoId: Int) data class RepositoryChangedDto(val repoId: Long)
@RestController @RestController
@RequestMapping("/gitlab") @RequestMapping("/gitlab")
class GitlabController(private val gitlabService: GitlabService) { class GitlabController(private val gitlabService: GitlabService) {
...@@ -15,6 +15,7 @@ class GitlabController(private val gitlabService: GitlabService) { ...@@ -15,6 +15,7 @@ class GitlabController(private val gitlabService: GitlabService) {
@PostMapping("/repoChanged") @PostMapping("/repoChanged")
fun repoChanged(@RequestBody repositoryChangedDto: RepositoryChangedDto) { fun repoChanged(@RequestBody repositoryChangedDto: RepositoryChangedDto) {
logger.info("Repo changed POST request for ID ${repositoryChangedDto.repoId} received.")
gitlabService.queryRepo(repositoryChangedDto.repoId) gitlabService.queryRepo(repositoryChangedDto.repoId)
} }
} }
\ No newline at end of file
package de.fraunhofer.iem.dataprovider.gitlab package de.fraunhofer.iem.dataprovider.gitlab
import de.fraunhofer.iem.dataprovider.logger.getLogger
import org.eclipse.jgit.api.Git
import org.gitlab4j.api.GitLabApi import org.gitlab4j.api.GitLabApi
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
@Service @Service
class GitlabService { class GitlabService(val gitlabConfiguration: GitlabConfiguration) {
@Autowired private val logger = getLogger(javaClass)
private lateinit var gitlabConfiguration: GitlabConfiguration private var gitlabApi = GitLabApi(gitlabConfiguration.host, gitlabConfiguration.accessToken)
fun queryRepo(repoId: Long) {
// private val gitlabApi = GitLabApi(gitlabConfiguration.host, gitlabConfiguration.accessToken) val project = gitlabApi.projectApi.getProject(repoId)
fun queryRepo(repoId: Int) { val projectUri = project.sshUrlToRepo
println(gitlabConfiguration.host) // val git: Git = Git.cloneRepository()
println(gitlabConfiguration.accessToken) // .setURI("https://github.com/eclipse/jgit.git")
// .setDirectory("/path/to/repo")
// .call()
} }
} }
\ No newline at end of file
spring.config.import=optional:classpath:.env[.properties] spring.config.import=optional:classpath:.env[.properties]
OPENCODE_GITLAB_URL="https://gitlab.opencode.de/" OPENCODE_GITLAB_URL=https://gitlab.opencode.de/
OPENCODE_GITLAB_TOKEN=${OPENCODE_TOKEN} OPENCODE_GITLAB_TOKEN=${OPENCODE_TOKEN}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.