Skip to content

Commit

Permalink
improve jenkins lock format
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkyAI committed Jan 23, 2021
1 parent 338bb77 commit 42b332d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
9 changes: 5 additions & 4 deletions core/src/main/kotlin/voodoo/builder/Resolve.kt
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ suspend fun resolve(
logger.info { "entry already resolved ${entry.id}" }
return@filter false
}
mutableEntryMap.containsKey(entry.id) -> {
logger.info { "entry already added ${entry.id} : ${mutableEntryMap[entry.id]}" }
return@filter false
}
// mutableEntryMap.containsKey(entry.id) -> {
// logger.info { "entry already added ${entry.id} : ${mutableEntryMap[entry.id]}" }
// return@filter false
// }

// newEntries.any { it.id == entry.id } -> {
// logger.info("entry already in queue ${entry.id}")
// continue
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/kotlin/voodoo/data/lock/LockEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ sealed class LockEntry() : CommonLockModule, Comparable<LockEntry> {
val jenkinsUrl: String = "",
val job: String = "",
val buildNumber: Int = -1,
val artifactRelativePath: String,
val artifactFileName: String,
val fileNameRegex: String = ".*(?<!-sources\\.jar)(?<!-api\\.jar)(?<!-deobf\\.jar)(?<!-lib\\.jar)(?<!-slim\\.jar)$"
) : LockEntry() {
override val providerType = JenkinsProvider.id
Expand Down
13 changes: 8 additions & 5 deletions core/src/main/kotlin/voodoo/provider/JenkinsProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ object JenkinsProvider : ProviderBase("Jenkins Provider") {
val job = job(entry.job, entry.jenkinsUrl)
val buildNumber = job.lastSuccessfulBuild?.number ?: throw IllegalStateException("buildnumber not set")
val common = entry.lockCommon()
val artifact = artifact(entry.job, entry.jenkinsUrl, buildNumber, entry.fileNameRegex)
return LockEntry.Jenkins(
id = common.id,
path = common.path,
Expand All @@ -53,25 +54,27 @@ object JenkinsProvider : ProviderBase("Jenkins Provider") {
jenkinsUrl = entry.jenkinsUrl,
job = entry.job,
buildNumber = buildNumber,
fileNameRegex = entry.fileNameRegex
fileNameRegex = entry.fileNameRegex,
artifactRelativePath = artifact.relativePath,
artifactFileName = artifact.fileName
)
}

suspend fun getDownloadUrl(
entry: LockEntry.Jenkins
): Pair<String, String> {
val build = build(entry.job, entry.jenkinsUrl, entry.buildNumber)
val artifact = artifact(entry.job, entry.jenkinsUrl, entry.buildNumber, entry.fileNameRegex)
val url = build.url + "artifact/" + artifact.relativePath
return url to artifact.fileName
// val artifact = artifact(entry.job, entry.jenkinsUrl, entry.buildNumber, entry.fileNameRegex)
val url = build.url + "artifact/" + entry.artifactRelativePath
return url to entry.artifactFileName
}

override suspend fun download(
stopwatch: Stopwatch,
entry: LockEntry,
targetFolder: File,
cacheDir: File
): Pair<String?, File>? = stopwatch {
): Pair<String?, File> = stopwatch {
entry as LockEntry.Jenkins
require(entry.job.isNotBlank()) { "entry: '${entry.id}' does not have the jenkins job set" }
// if (entry.job.isBlank()) {
Expand Down

0 comments on commit 42b332d

Please sign in to comment.