-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add image-builder support for Jenkins (#12598)
* Use GIT_COMMIT as pull request head for jenkins * Add support for Jenkins * Fix signing step success value * Add ability to save report to file * gomod(deps): bump github.com/spf13/pflag from 1.0.5 to 1.0.6 (#12599) Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.5 to 1.0.6. - [Release notes](https://github.com/spf13/pflag/releases) - [Commits](spf13/pflag@v1.0.5...v1.0.6) --- updated-dependencies: - dependency-name: github.com/spf13/pflag dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * gomod(deps): bump github.com/zricethezav/gitleaks/v8 (#12600) Bumps [github.com/zricethezav/gitleaks/v8](https://github.com/zricethezav/gitleaks) from 8.23.2 to 8.23.3. - [Release notes](https://github.com/zricethezav/gitleaks/releases) - [Changelog](https://github.com/gitleaks/gitleaks/blob/master/.goreleaser.yml) - [Commits](gitleaks/gitleaks@v8.23.2...v8.23.3) --- updated-dependencies: - dependency-name: github.com/zricethezav/gitleaks/v8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Wojciech Sołtys <[email protected]> * gomod(deps): bump google.golang.org/api from 0.218.0 to 0.219.0 (#12601) Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.218.0 to 0.219.0. - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](googleapis/google-api-go-client@v0.218.0...v0.219.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bumping test-infra and testimages (#12603) No eu.gcr.io/kyma-project/test-infra/ changes. europe-docker.pkg.dev/kyma-project/prod/ changes: 67a01b6...45cbab5 (2025‑01‑24 → 2025‑01‑30) * Bumping sec-scanners-config.yaml (#12606) * Delete prow/jobs/kyma-project/test-infra/kyma-bot.yaml (#12607) * Update config.yaml (#12604) * Fix linter --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Wojciech Sołtys <[email protected]> Co-authored-by: Kyma Bot <[email protected]>
- Loading branch information
1 parent
b75245d
commit e2cd0cf
Showing
8 changed files
with
223 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package pipelines | ||
|
||
import "fmt" | ||
|
||
func SetVariable(name string, value interface{}, isSecret bool, isOutput bool) { | ||
fmt.Printf("##vso[task.setvariable variable=%s;issecret=%v;isoutput=%v]%v\n", name, isSecret, isOutput, value) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package imagebuilder | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"regexp" | ||
) | ||
|
||
// reportRegex is a regular expression that matches the image build report | ||
var reportRegex = regexp.MustCompile(`(?s)---IMAGE BUILD REPORT---\n(.*)\n---END OF IMAGE BUILD REPORT---`) | ||
|
||
type BuildReport struct { | ||
Status string `json:"status"` | ||
IsSigned bool `json:"signed"` | ||
IsProduction bool `json:"is_production"` | ||
ImageSpec ImageSpec `json:"image_spec"` | ||
} | ||
|
||
type ImageSpec struct { | ||
Name string `json:"image_name"` | ||
Tags []string `json:"tags"` | ||
RepositoryPath string `json:"repository_path"` | ||
} | ||
|
||
func (br *BuildReport) GetImages() []string { | ||
var images []string | ||
|
||
if br == nil { | ||
return images | ||
} | ||
|
||
for _, tag := range br.ImageSpec.Tags { | ||
images = append(images, fmt.Sprintf("%s%s:%s", br.ImageSpec.RepositoryPath, br.ImageSpec.Name, tag)) | ||
} | ||
|
||
return images | ||
} | ||
|
||
func NewBuildReportFromLogs(log string) (*BuildReport, error) { | ||
matches := reportRegex.FindStringSubmatch(log) | ||
if len(matches) < 2 { | ||
return nil, nil | ||
} | ||
|
||
var report BuildReport | ||
if err := json.Unmarshal([]byte(matches[1]), &report); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &report, nil | ||
} | ||
|
||
func WriteReportToFile(report *BuildReport, path string) error { | ||
data, err := json.Marshal(report) | ||
if err != nil { | ||
return fmt.Errorf("failed to marshal report: %w", err) | ||
} | ||
|
||
file, err := os.Open(path) | ||
if err != nil { | ||
return fmt.Errorf("failed to open file: %w", err) | ||
} | ||
defer file.Close() | ||
|
||
if _, err := file.Write(data); err != nil { | ||
return fmt.Errorf("failed to write report to file: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package imagebuilder | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestPipelines(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Image Builder Suite") | ||
} |
Oops, something went wrong.