Skip to content

Commit

Permalink
feat(bake): parse version from kork Artifacts (spinnaker#2357)
Browse files Browse the repository at this point in the history
  • Loading branch information
emjburns authored Aug 9, 2018
1 parent 578e3c6 commit b39e74f
Show file tree
Hide file tree
Showing 4 changed files with 333 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.netflix.spinnaker.orca.bakery.tasks

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.kork.artifacts.model.Artifact
import com.netflix.spinnaker.orca.ExecutionStatus
import com.netflix.spinnaker.orca.RetryableTask
import com.netflix.spinnaker.orca.TaskResult
Expand Down Expand Up @@ -131,7 +132,10 @@ class CreateBakeTask implements RetryableTask {
packageType = new OperatingSystem(stage.context.baseOs as String).getPackageType()
}

List<Artifact> artifacts = artifactResolver.getAllArtifacts(stage.getExecution())

PackageInfo packageInfo = new PackageInfo(stage,
artifacts,
packageType.packageType,
packageType.versionDelimiter,
extractBuildDetails,
Expand All @@ -140,6 +144,8 @@ class CreateBakeTask implements RetryableTask {

Map requestMap = packageInfo.findTargetPackage(allowMissingPackageInstallation)

// if the field "packageArtifactIds" is present in the context, because it was set in the UI,
// this will resolve those ids into real artifacts and then put them in List<Artifact> packageArtifacts
requestMap.packageArtifacts = stage.context.packageArtifactIds.collect { String artifactId ->
artifactResolver.getBoundArtifactForId(stage, artifactId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class CreateBakeTaskSpec extends Specification {
Stage bakeStage
def mapper = OrcaObjectMapper.newInstance()

ArtifactResolver artifactResolver = Stub() {
getAllArtifacts(_) >> []
}

@Shared
def runningStatus = new BakeStatus(id: randomUUID(), state: RUNNING)

Expand Down Expand Up @@ -205,6 +209,7 @@ class CreateBakeTaskSpec extends Specification {

def setup() {
task.mapper = mapper
task.artifactResolver = artifactResolver
bakeStage = pipeline.stages.first()
}

Expand Down Expand Up @@ -349,7 +354,7 @@ class CreateBakeTaskSpec extends Specification {
then:
IllegalStateException ise = thrown(IllegalStateException)
ise.message.startsWith("Found build artifact in Jenkins")
ise.message.startsWith("Found build artifact in both Jenkins")
}
def "outputs the status of the bake"() {
Expand Down Expand Up @@ -820,6 +825,7 @@ class CreateBakeTaskSpec extends Specification {

then:
2 * task.artifactResolver.getBoundArtifactForId(stage, _) >> new Artifact()
1 * task.artifactResolver.getAllArtifacts(_) >> []
bakeResult.getPackageArtifacts().size() == 2
}

Expand All @@ -837,6 +843,7 @@ class CreateBakeTaskSpec extends Specification {

then:
0 * task.artifactResolver.getBoundArtifactForId(*_) >> new Artifact()
1 * task.artifactResolver.getAllArtifacts(_) >> []
bakeResult.getPackageArtifacts().size() == 0
}

Expand All @@ -855,6 +862,7 @@ class CreateBakeTaskSpec extends Specification {
then:
noExceptionThrown()
2 * task.artifactResolver.getBoundArtifactForId(stage, _) >> new Artifact()
1 * task.artifactResolver.getAllArtifacts(_) >> []
bakeResult.getPackageArtifacts().size() == 2
}
}
Loading

0 comments on commit b39e74f

Please sign in to comment.