diff --git a/deploy/crds/base/jvmbuildservice.io_dependencybuilds.yaml b/deploy/crds/base/jvmbuildservice.io_dependencybuilds.yaml index 6ea6a18e4..19aa3b279 100644 --- a/deploy/crds/base/jvmbuildservice.io_dependencybuilds.yaml +++ b/deploy/crds/base/jvmbuildservice.io_dependencybuilds.yaml @@ -86,6 +86,16 @@ spec: items: type: string type: array + gitArchive: + description: The git archive source information + properties: + sha: + type: string + tag: + type: string + url: + type: string + type: object hermeticBuildImage: description: The hermetic build image produced by the build diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/DeployCommand.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/DeployCommand.java index 50cd26265..cb3c8e3e2 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/DeployCommand.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/DeployCommand.java @@ -157,17 +157,19 @@ public DeployCommand(BeanManager beanManager, public void run() { try { + Set gavs = new HashSet<>(); + Map> contaminatedPaths = new HashMap<>(); + Map contaminatedGavs = new HashMap<>(); + Git.GitStatus archivedSourceTags = new Git.GitStatus(); + // Save the source first regardless of deployment checks if (isNotEmpty(gitIdentity) && gitToken.isPresent()) { Log.infof("Git credentials are identity '%s' and URL '%s'", gitIdentity, gitURL); var git = Git.builder(gitURL, gitIdentity, gitToken.get(), gitDisableSSLVerification); git.create(scmUri); - git.add(sourcePath, commit, imageId); + archivedSourceTags = git.add(sourcePath, commit, imageId); } - Set gavs = new HashSet<>(); - Map> contaminatedPaths = new HashMap<>(); - Map contaminatedGavs = new HashMap<>(); // Represents directories that should not be deployed i.e. if a single artifact (barring test jars) is // contaminated then none of the artifacts will be deployed. Set toRemove = new HashSet<>(); @@ -337,13 +339,15 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { newContaminates.add(i.getValue()); } String serialisedContaminants = ResultsUpdater.MAPPER.writeValueAsString(newContaminates); + String serialisedGitArchive = ResultsUpdater.MAPPER.writeValueAsString(archivedSourceTags); Log.infof("Updating results %s with contaminants %s and deployed resources %s", taskRun, serialisedContaminants, gavs); resultsUpdater.updateResults(taskRun, Map.of( "CONTAMINANTS", serialisedContaminants, "DEPLOYED_RESOURCES", String.join(",", gavs), "IMAGE_URL", imageName == null ? "" : imageName, - "IMAGE_DIGEST", imageDigest == null ? "" : "sha256:" + imageDigest)); + "IMAGE_DIGEST", imageDigest == null ? "" : "sha256:" + imageDigest, + "GIT_ARCHIVE", serialisedGitArchive)); } } catch (Exception e) { Log.error("Deployment failed", e); diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/Git.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/Git.java index 71bc59c4e..1628480c3 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/Git.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/Git.java @@ -8,6 +8,7 @@ import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; +import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.PushResult; @@ -24,7 +25,7 @@ public abstract class Git { public abstract void create(String name) throws IOException, URISyntaxException; - public abstract void add(Path path, String commit, String imageId) + public abstract GitStatus add(Path path, String commit, String imageId) throws IOException; /** @@ -62,7 +63,7 @@ public static Git builder(String endpoint, String identity, String token, boolea } } - protected void pushRepository(Path path, String httpTransportUrl, String commit, String imageId) { + protected GitStatus pushRepository(Path path, String httpTransportUrl, String commit, String imageId) { try (var jGit = org.eclipse.jgit.api.Git.init().setDirectory(path.toFile()).call()) { // Find the tag name associated with the commit. Then append the unique imageId. This is from the Go code // and is a hash of abr.Status.SCMInfo.SCMURL + abr.Status.SCMInfo.Tag + abr.Status.SCMInfo.Path @@ -87,6 +88,7 @@ protected void pushRepository(Path path, String httpTransportUrl, String commit, Ref tagRefStable = jGit.tag().setAnnotated(true).setName(tagName + "-" + imageId).setForceUpdate(true).call(); Ref tagRefUnique = jGit.tag().setAnnotated(true).setName(tagName + "-" + UUID.randomUUID()).setForceUpdate(true) .call(); + Iterable results = jGit.push().setForce(true).setRemote("origin") .add(jRepo.getBranch()) // Push the default branch else GitHub doesn't show the code. .add(tagRefStable) @@ -95,7 +97,8 @@ protected void pushRepository(Path path, String httpTransportUrl, String commit, for (PushResult result : results) { result.getRemoteUpdates().forEach(r -> { - if (!r.getStatus().equals(RemoteRefUpdate.Status.OK)) { + if (!r.getStatus().equals(RemoteRefUpdate.Status.OK) + && !r.getStatus().equals(RemoteRefUpdate.Status.UP_TO_DATE)) { Log.errorf("Push failure " + r); throw new RuntimeException("Failed to push updates due to " + r.getMessage()); } @@ -103,6 +106,9 @@ protected void pushRepository(Path path, String httpTransportUrl, String commit, Log.debugf("Pushed " + result.getMessages() + " " + result.getURI() + " updates: " + result.getRemoteUpdates()); } + + return new GitStatus(httpTransportUrl, Repository.shortenRefName(tagRefUnique.getName()), + jRepo.getRefDatabase().peel(tagRefUnique).getPeeledObjectId().getName()); } catch (GitAPIException | IOException e) { throw new RuntimeException(e); } @@ -125,4 +131,24 @@ protected String parseScmURI(String scmUri) } abstract String groupSplit(); + + public static class GitStatus { + public String url; + public String tag; + public String sha; + + public GitStatus() { + } + + public GitStatus(String url, String tag, String sha) { + this.url = url; + this.tag = tag; + this.sha = sha; + } + + @Override + public String toString() { + return "GitStatus{url='" + url + "', tag='" + tag + "', sha='" + sha + "'}"; + } + } } diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/GitHub.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/GitHub.java index 240bf72fc..92fe9dc0f 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/GitHub.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/GitHub.java @@ -62,6 +62,7 @@ public void create(String scmUri) if (type == Type.USER) { repository = github.getUser(owner).getRepository(name); if (repository == null) { + Log.infof("Creating repository with name %s", name); repository = github.createRepository(name) .wiki(false) .defaultBranch("main") @@ -73,6 +74,7 @@ public void create(String scmUri) } else { repository = github.getOrganization(owner).getRepository(name); if (repository == null) { + Log.infof("Creating repository with name %s", name); repository = github.getOrganization(owner).createRepository(name) .wiki(false) .defaultBranch("main") @@ -85,11 +87,11 @@ public void create(String scmUri) } @Override - public void add(Path path, String commit, String imageId) { + public GitStatus add(Path path, String commit, String imageId) { if (repository == null) { throw new RuntimeException("Call create first"); } - pushRepository(path, repository.getHttpTransportUrl(), commit, imageId); + return pushRepository(path, repository.getHttpTransportUrl(), commit, imageId); } @Override diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/GitLab.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/GitLab.java index ba726eeb5..206f0e475 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/GitLab.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/deploy/git/GitLab.java @@ -40,7 +40,6 @@ public GitLab(String endpoint, String identity, String token, boolean ssl) { public void create(String scmUri) throws URISyntaxException { String name = parseScmURI(scmUri); - Log.infof("Creating repository with name %s", name); try { project = gitLabApi.getProjectApi().getUserProjectsStream(owner, new ProjectFilter().withSearch(name)) .filter(p -> p.getName().equals(name)) @@ -49,6 +48,7 @@ public void create(String scmUri) Log.warnf("Repository %s already exists", name); } else { // Can't set public visibility after creation for some reason with this API. + Log.infof("Creating repository with name %s", name); project = gitLabApi.getProjectApi().createProject(name, null, null, @@ -66,12 +66,12 @@ public void create(String scmUri) } @Override - public void add(Path path, String commit, String imageId) + public GitStatus add(Path path, String commit, String imageId) throws IOException { if (project == null) { throw new RuntimeException("Call create first"); } - pushRepository(path, project.getHttpUrlToRepo(), commit, imageId); + return pushRepository(path, project.getHttpUrlToRepo(), commit, imageId); } @Override diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/DiffUtils.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/DiffUtils.java index 8a3587edc..3ba20fb04 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/DiffUtils.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/DiffUtils.java @@ -10,12 +10,10 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.builder.DiffResult; -import org.jboss.logging.Logger; import com.redhat.hacbs.container.verifier.asm.AsmDiffable; public class DiffUtils { - private static final Logger Log = Logger.getLogger(DiffUtils.class); public record DiffResults(Set shared, Set added, Set deleted, Map> diffResults, diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/MavenUtils.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/MavenUtils.java index d381957e1..4b59231e1 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/MavenUtils.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/MavenUtils.java @@ -28,10 +28,10 @@ import org.eclipse.aether.util.repository.AuthenticationBuilder; import org.eclipse.aether.util.repository.DefaultAuthenticationSelector; import org.eclipse.aether.util.repository.DefaultMirrorSelector; -import org.jboss.logging.Logger; + +import io.quarkus.logging.Log; public class MavenUtils { - private static final Logger Log = Logger.getLogger(MavenUtils.class); public static Settings newSettings(Path globalSettingsFile, Path settingsFile) { try { diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/VerifyBuiltArtifactsCommand.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/VerifyBuiltArtifactsCommand.java index e8dec461b..b5434f920 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/VerifyBuiltArtifactsCommand.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/VerifyBuiltArtifactsCommand.java @@ -36,20 +36,19 @@ import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.RemoteRepository.Builder; -import org.jboss.logging.Logger; import com.redhat.hacbs.container.results.ResultsUpdater; import com.redhat.hacbs.container.verifier.asm.JarInfo; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException; +import io.quarkus.logging.Log; import picocli.CommandLine; import picocli.CommandLine.Command; import picocli.CommandLine.Option; @Command(name = "verify-built-artifacts") public class VerifyBuiltArtifactsCommand implements Callable { - private static final Logger Log = Logger.getLogger(VerifyBuiltArtifactsCommand.class); static class LocalOptions { @Option(required = true, names = { "-of", "--original-file" }) @@ -139,7 +138,6 @@ public Integer call() { session.setReadOnly(); } - Log.debugf("Deploy path: %s", options.mavenOptions.deployPath); var futureResults = new HashMap>>(); Files.walkFileTree(options.mavenOptions.deployPath, new SimpleFileVisitor<>() { @@ -191,7 +189,7 @@ public List call() throws Exception { } if (taskRunName != null) { var json = ResultsUpdater.MAPPER.writeValueAsString(verificationResults); - io.quarkus.logging.Log.infof("Writing verification results %s", json); + Log.infof("Writing verification results %s", json); resultsUpdater.get().updateResults(taskRunName, Map.of("VERIFICATION_RESULTS", json)); } return (failed && !reportOnly ? 1 : 0); diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/asm/JarInfo.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/asm/JarInfo.java index a90bd4ee4..94cf4fe3e 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/asm/JarInfo.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/verifier/asm/JarInfo.java @@ -16,15 +16,14 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; -import org.jboss.logging.Logger; import org.objectweb.asm.ClassReader; import org.objectweb.asm.tree.ClassNode; import com.redhat.hacbs.container.verifier.DiffUtils; -public record JarInfo(String name, Map classes) implements AsmDiffable { +import io.quarkus.logging.Log; - private static final Logger Log = Logger.getLogger(JarInfo.class); +public record JarInfo(String name, Map classes) implements AsmDiffable { // diffClass excluding name diff --git a/java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/analyser/deploy/git/GitTest.java b/java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/analyser/deploy/git/GitTest.java index 31095c655..c36340777 100644 --- a/java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/analyser/deploy/git/GitTest.java +++ b/java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/analyser/deploy/git/GitTest.java @@ -15,6 +15,8 @@ import org.apache.commons.io.FileUtils; import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.lib.Ref; +import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.transport.TagOpt; import org.eclipse.jgit.transport.URIish; import org.junit.jupiter.api.BeforeEach; @@ -54,6 +56,7 @@ public void testPush() Path initialRepo = Files.createTempDirectory("initial-repo"); Path testRepo = Files.createTempDirectory("test-repo"); String testRepoURI = "file://" + testRepo; + String imageID = "75ecd81c7a2b384151c990975eb1dd10"; try (var testRepository = org.eclipse.jgit.api.Git.init().setDirectory(testRepo.toFile()).call(); var initialRepository = org.eclipse.jgit.api.Git.init().setDirectory(initialRepo.toFile()).call()) { Path repoRoot = Paths.get(Objects.requireNonNull(getClass().getResource("/")).toURI()).getParent().getParent() @@ -74,7 +77,8 @@ public void create(String name) { } @Override - public void add(Path path, String commit, String imageId) { + public GitStatus add(Path path, String commit, String imageId) { + return null; } @Override @@ -82,11 +86,11 @@ public String groupSplit() { return null; } }; - test.pushRepository( + Git.GitStatus tagResults = test.pushRepository( initialRepo, testRepoURI, "c396268fb90335bde5c9272b9a194c3d4302bf24", - "75ecd81c7a2b384151c990975eb1dd10"); + imageID); List logRecords = LogCollectingTestResource.current().getRecords(); @@ -98,9 +102,18 @@ public String groupSplit() { .anyMatch( r -> LogCollectingTestResource.format(r).matches("Updating current origin of.*to " + testRepoURI))); - assertEquals(2, testRepository.tagList().call().size()); - assertTrue(testRepository.tagList().call().stream() - .anyMatch(r -> r.getName().equals("refs/tags/0.1-75ecd81c7a2b384151c990975eb1dd10"))); + List tags = testRepository.tagList().call(); + assertEquals(2, tags.size()); + assertTrue(tags.stream().anyMatch(r -> r.getName().equals("refs/tags/0.1-75ecd81c7a2b384151c990975eb1dd10"))); + + var found = tags.stream().filter(t -> Repository.shortenRefName(t.getName()).matches(tagResults.tag)).findFirst(); + assertTrue(found.isPresent()); + assertTrue(tagResults.url.contains(testRepoURI)); + assertTrue(tagResults.sha.matches(testRepository.getRepository() + .getRefDatabase() + .peel(found.get()) + .getPeeledObjectId() + .getName())); } } diff --git a/java-components/cache/src/main/java/com/redhat/hacbs/artifactcache/services/CachePomScmLocator.java b/java-components/cache/src/main/java/com/redhat/hacbs/artifactcache/services/CachePomScmLocator.java index 62ce2cadb..d207ba078 100644 --- a/java-components/cache/src/main/java/com/redhat/hacbs/artifactcache/services/CachePomScmLocator.java +++ b/java-components/cache/src/main/java/com/redhat/hacbs/artifactcache/services/CachePomScmLocator.java @@ -9,14 +9,14 @@ import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.jboss.logging.Logger; import com.redhat.hacbs.recipies.scm.AbstractPomScmLocator; +import io.quarkus.logging.Log; + @ApplicationScoped public class CachePomScmLocator extends AbstractPomScmLocator { - private static final Logger log = Logger.getLogger(CachePomScmLocator.class); @Inject CacheFacade cache; @@ -27,7 +27,7 @@ protected AbstractPomScmLocator.PomClient createPomClient() { public Optional getPom(String group, String artifact, String version) { var response = cache.getArtifactFile("default", group.replace(".", "/"), artifact, version, artifact + "-" + version + ".pom", false); - if (!response.isPresent()) { + if (response.isEmpty()) { return Optional.empty(); } try { @@ -38,7 +38,7 @@ public Optional getPom(String group, String artifact, String version) { } } catch (Exception e) { - log.errorf(e, "Failed to get pom for %s:%s:%s", group, artifact, version); + Log.errorf(e, "Failed to get pom for %s:%s:%s", group, artifact, version); return Optional.empty(); } finally { try { diff --git a/java-components/resource-model/src/main/resources/crds/jvmbuildservice.io_dependencybuilds.yaml b/java-components/resource-model/src/main/resources/crds/jvmbuildservice.io_dependencybuilds.yaml index 6ea6a18e4..19aa3b279 100644 --- a/java-components/resource-model/src/main/resources/crds/jvmbuildservice.io_dependencybuilds.yaml +++ b/java-components/resource-model/src/main/resources/crds/jvmbuildservice.io_dependencybuilds.yaml @@ -86,6 +86,16 @@ spec: items: type: string type: array + gitArchive: + description: The git archive source information + properties: + sha: + type: string + tag: + type: string + url: + type: string + type: object hermeticBuildImage: description: The hermetic build image produced by the build diff --git a/pkg/apis/jvmbuildservice/v1alpha1/dependencybuild_types.go b/pkg/apis/jvmbuildservice/v1alpha1/dependencybuild_types.go index f00c6aabf..16514bfcc 100644 --- a/pkg/apis/jvmbuildservice/v1alpha1/dependencybuild_types.go +++ b/pkg/apis/jvmbuildservice/v1alpha1/dependencybuild_types.go @@ -92,11 +92,19 @@ type BuildPipelineRunResults struct { Gavs []string `json:"gavs,omitempty"` // The hermetic build image produced by the build HermeticBuildImage string `json:"hermeticBuildImage,omitempty"` + // The git archive source information + GitArchive GitArchive `json:"gitArchive,omitempty"` // The Tekton results PipelineResults *PipelineResults `json:"pipelineResults,omitempty"` } +type GitArchive struct { + URL string `json:"url,omitempty"` + Tag string `json:"tag,omitempty"` + SHA string `json:"sha,omitempty"` +} + func (r *DependencyBuildStatus) GetBuildPipelineRun(pipeline string) *BuildAttempt { for i := range r.BuildAttempts { ba := r.BuildAttempts[i] diff --git a/pkg/reconciler/artifactbuild/artifactbuild.go b/pkg/reconciler/artifactbuild/artifactbuild.go index 3d55a559a..91816bea9 100644 --- a/pkg/reconciler/artifactbuild/artifactbuild.go +++ b/pkg/reconciler/artifactbuild/artifactbuild.go @@ -36,14 +36,6 @@ const ( DependencyBuildIdLabel = "jvmbuildservice.io/dependencybuild-id" PipelineRunLabel = "jvmbuildservice.io/pipelinerun" - PipelineResultScmUrl = "scm-url" - PipelineResultScmTag = "scm-tag" - PipelineResultScmHash = "scm-hash" - PipelineResultScmType = "scm-type" - PipelineResultContextPath = "context" - PipelineResultMessage = "message" - PipelineResultPrivate = "private" - PreBuildTaskName = "pre-build" BuildTaskName = "build" HermeticBuildTaskName = "hermetic-build" @@ -54,12 +46,13 @@ const ( PipelineResultVerificationResult = "VERIFICATION_RESULTS" PipelineResultPassedVerification = "PASSED_VERIFICATION" //#nosec PipelineResultHermeticBuildImage = "HERMETIC_BUILD_IMAGE" + PipelineResultGitArchive = "GIT_ARCHIVE" PipelineResultGavs = "GAVS" RebuildAnnotation = "jvmbuildservice.io/rebuild" - //annotation that is applied after a rebuild, it will affect the dependencybuild behaviour + // RebuiltAnnotation annotation that is applied after a rebuild, it will affect the dependencybuild behaviour RebuiltAnnotation = "jvmbuildservice.io/rebuilt" - //if this annotation is present it will be deleted after a set time to live + // HoursToLive if this annotation is present it will be deleted after a set time to live //useful when doing builds that are being deployed to maven, and you don't want to accumulate them in the cluster HoursToLive = "jvmbuildservice.io/hours-to-live" ) diff --git a/pkg/reconciler/dependencybuild/buildrecipeyaml.go b/pkg/reconciler/dependencybuild/buildrecipeyaml.go index 5ec8ebe4d..bf05dcc3e 100644 --- a/pkg/reconciler/dependencybuild/buildrecipeyaml.go +++ b/pkg/reconciler/dependencybuild/buildrecipeyaml.go @@ -248,6 +248,7 @@ func createPipelineSpec(tool string, commitTime int64, jbsConfig *v1alpha12.JBSC {Name: PipelineResultImageDigest}, {Name: artifactbuild.PipelineResultPassedVerification}, {Name: artifactbuild.PipelineResultVerificationResult}, + {Name: artifactbuild.PipelineResultGitArchive}, }...), Steps: []pipelinev1beta1.Step{ { @@ -296,6 +297,7 @@ func createPipelineSpec(tool string, commitTime int64, jbsConfig *v1alpha12.JBSC {Name: PipelineResultImageDigest}, {Name: artifactbuild.PipelineResultPassedVerification}, {Name: artifactbuild.PipelineResultVerificationResult}, + {Name: artifactbuild.PipelineResultGitArchive}, }, Steps: []pipelinev1beta1.Step{ { diff --git a/pkg/reconciler/dependencybuild/dependencybuild.go b/pkg/reconciler/dependencybuild/dependencybuild.go index 2ced02e03..10bb1adf6 100644 --- a/pkg/reconciler/dependencybuild/dependencybuild.go +++ b/pkg/reconciler/dependencybuild/dependencybuild.go @@ -652,6 +652,8 @@ func (r *ReconcileDependencyBuild) handleBuildPipelineRunReceived(ctx context.Co var verificationResults string var hermeticBuildImage string var deployed []string + var gitArchive v1alpha1.GitArchive + for _, i := range pr.Status.Results { if i.Name == PipelineResultImage { image = i.Value.StringVal @@ -668,8 +670,13 @@ func (r *ReconcileDependencyBuild) handleBuildPipelineRunReceived(ctx context.Co parseBool, _ := strconv.ParseBool(i.Value.StringVal) passedVerification = !parseBool } else if i.Name == artifactbuild.PipelineResultVerificationResult { + // Note: The TaskRun stores this as + // VERIFICATION_RESULTS {"commons-lang:commons-lang:jar:2.5":[]} + // But this is now stored as + // "verificationFailures": "{\"commons-lang:commons-lang:jar:2.5\":[]}" verificationResults = i.Value.StringVal } else if i.Name == artifactbuild.PipelineResultGavs { + // TODO: What is the difference between this and PipelineResultDeployedResources? deployed := strings.Split(i.Value.StringVal, ",") db.Status.DeployedArtifacts = deployed } else if i.Name == artifactbuild.PipelineResultDeployedResources && len(i.Value.StringVal) > 0 { @@ -677,6 +684,11 @@ func (r *ReconcileDependencyBuild) handleBuildPipelineRunReceived(ctx context.Co deployed = strings.Split(i.Value.StringVal, ",") } else if i.Name == artifactbuild.PipelineResultHermeticBuildImage { hermeticBuildImage = i.Value.StringVal + } else if i.Name == artifactbuild.PipelineResultGitArchive { + err := json.Unmarshal([]byte(i.Value.StringVal), &gitArchive) + if err != nil { + return reconcile.Result{}, err + } } } err = r.createRebuiltArtifacts(ctx, log, pr, db, image, digest, deployed) @@ -690,8 +702,10 @@ func (r *ReconcileDependencyBuild) handleBuildPipelineRunReceived(ctx context.Co Verified: passedVerification, VerificationResults: verificationResults, Gavs: deployed, + GitArchive: gitArchive, HermeticBuildImage: hermeticBuildImage, } + problemContaminates := db.Status.ProblemContaminates() if len(problemContaminates) == 0 { db.Status.State = v1alpha1.DependencyBuildStateComplete