From 9b102b40bf9d2e1db295a41be72ef7f24311b94f Mon Sep 17 00:00:00 2001 From: dekiel Date: Tue, 25 Jun 2024 14:39:15 +0200 Subject: [PATCH 1/2] Fix empty ado logs used to extract built images. --- cmd/image-builder/main.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/image-builder/main.go b/cmd/image-builder/main.go index 3578e1e5eef8..cd9bbc44d34f 100644 --- a/cmd/image-builder/main.go +++ b/cmd/image-builder/main.go @@ -345,7 +345,7 @@ func buildInADO(o options) error { if err != nil { fmt.Printf("Can't read ADO pipeline run logs, failed creating ADO build client, err: %s", err) } - logs, err := adopipelines.GetRunLogs(ctx, adoBuildClient, &http.Client{}, o.AdoConfig.GetADOConfig(), pipelineRun.Id, o.azureAccessToken) + logs, err = adopipelines.GetRunLogs(ctx, adoBuildClient, &http.Client{}, o.AdoConfig.GetADOConfig(), pipelineRun.Id, o.azureAccessToken) if err != nil { fmt.Printf("Failed read ADO pipeline run logs, err: %s", err) } else { @@ -360,9 +360,11 @@ func buildInADO(o options) error { // buildInADO should return required data and caller should handle it. // if run in github actions, set output parameters if o.ciSystem == GithubActions { + fmt.Println("Setting GitHub outputs.") var images []string if !o.dryRun { images = extractImagesFromADOLogs(logs) + fmt.Printf("Extracted built images from ADO logs: %v\n", images) } else { fmt.Println("Running in dry-run mode. Skipping extracting images and results from ADO.") images = []string{"registry/repo/image1:tag1", "registry/repo/image2:tag2"} @@ -372,8 +374,16 @@ func buildInADO(o options) error { return fmt.Errorf("cannot marshal list of images: %w", err) } - actions.SetOutput("images", string(data)) - actions.SetOutput("adoResult", string(*pipelineRunResult)) + err = actions.SetOutput("images", string(data)) + if err != nil { + return fmt.Errorf("cannot set images GitHub output: %w", err) + } + fmt.Println("images GitHub output set") + err = actions.SetOutput("adoResult", string(*pipelineRunResult)) + if err != nil { + return fmt.Errorf("cannot set adoResult GitHub output: %w", err) + } + fmt.Println("adoResult GitHub output set") } // Handle the ADO pipeline run failure. From 9351615c8a820af4cf9e0e8c64c025b2cd518320 Mon Sep 17 00:00:00 2001 From: dekiel Date: Wed, 26 Jun 2024 09:19:05 +0200 Subject: [PATCH 2/2] Use new version of image-builder with fix for empty images GitHub output. --- .github/actions/image-builder/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/image-builder/action.yml b/.github/actions/image-builder/action.yml index 0590293949ca..bd529177eaeb 100644 --- a/.github/actions/image-builder/action.yml +++ b/.github/actions/image-builder/action.yml @@ -78,7 +78,7 @@ runs: id: prepare-tags shell: bash - - uses: docker://europe-docker.pkg.dev/kyma-project/prod/image-builder:v20240624-9aa7af85 + - uses: docker://europe-docker.pkg.dev/kyma-project/prod/image-builder:v20240626-2f46eb74 id: build with: args: --name=${{ inputs.image-name }} --context=${{ inputs.context }} --dockerfile=${{ inputs.dockerfile }} --azure-access-token=${{ inputs.ado-token }} --oidc-token=${{ inputs.oidc-token }} ${{ steps.prepare-build-args.outputs.build-args }} ${{ steps.prepare-tags.outputs.tags }} --export-tags=${{ inputs.export-tags }} --config=${{ inputs.config }} --env-file=${{ inputs.env-file }} --build-in-ado=true \ No newline at end of file