-
Notifications
You must be signed in to change notification settings - Fork 32
Fix/rteco 562 jf twine incorrectly applies build properties to similar named files #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2a390ce
ae27089
ba947c1
7fa3be5
c1333b6
21b5b36
e084ea9
f60e8dc
e5f53e2
2871375
1120f16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,13 +155,11 @@ func (tc *TwineCommand) uploadAndCollectBuildInfo() error { | |
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| defer func() { | ||
| if buildInfo != nil && err != nil { | ||
| err = errors.Join(err, buildInfo.Clean()) | ||
| } | ||
| }() | ||
|
|
||
| var pythonModule *build.PythonModule | ||
| pythonModule, err = buildInfo.AddPythonModule("", pythonutils.Twine) | ||
| if err != nil { | ||
|
|
@@ -170,7 +168,6 @@ func (tc *TwineCommand) uploadAndCollectBuildInfo() error { | |
| if tc.buildConfiguration.GetModule() != "" { | ||
| pythonModule.SetName(tc.buildConfiguration.GetModule()) | ||
| } | ||
|
|
||
| artifacts, err := pythonModule.TwineUploadWithLogParsing(tc.args) | ||
| if err != nil { | ||
| return err | ||
|
|
@@ -181,7 +178,6 @@ func (tc *TwineCommand) uploadAndCollectBuildInfo() error { | |
| if err = pythonModule.AddArtifacts(artifacts); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| buildName, err := tc.buildConfiguration.GetBuildName() | ||
| if err != nil { | ||
| return err | ||
|
|
@@ -190,45 +186,41 @@ func (tc *TwineCommand) uploadAndCollectBuildInfo() error { | |
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| var fileInitials string | ||
| var filesSha256 []string | ||
| for _, arg := range artifacts { | ||
| if strings.HasSuffix(arg.Name, ".tar.gz") { | ||
| fileInitials = arg.Name | ||
| if arg.Sha256 != "" { | ||
| filesSha256 = append(filesSha256, arg.Sha256) | ||
| } | ||
| } | ||
|
|
||
| if len(filesSha256) == 0 { | ||
| return errors.New("could not find any files to upload") | ||
| } | ||
| searchParams := services.SearchParams{ | ||
| CommonParams: &servicesUtils.CommonParams{ | ||
| Aql: servicesUtils.Aql{ | ||
| ItemsFind: CreateAqlQueryForSearch(tc.targetRepo, fileInitials), | ||
| ItemsFind: CreateAqlQueryForSearchBySHA256(tc.targetRepo, filesSha256), | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| servicesManager, err := rtUtils.CreateServiceManager(tc.serverDetails, -1, 0, false) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| searchReader, err := servicesManager.SearchFiles(searchParams) | ||
| if err != nil { | ||
| log.Error("Failed to get uploaded twine package: ", err.Error()) | ||
| return err | ||
| } | ||
|
|
||
| timestamp := strconv.FormatInt(buildInfo.GetBuildTimestamp().UnixNano()/int64(time.Millisecond), 10) | ||
| propsParams := services.PropsParams{ | ||
| Reader: searchReader, | ||
| Props: fmt.Sprintf("build.name=%s;build.number=%s;build.timestamp=%s", buildName, buildNumber, timestamp), | ||
| } | ||
|
|
||
| _, err = servicesManager.SetProps(propsParams) | ||
| if err != nil { | ||
| log.Warn("Unable to set build properties: ", err, "\nThis may cause build to not properly link with artifact, please add build name and build number properties on the artifacts manually") | ||
| return err | ||
| } | ||
|
|
||
| log.Debug(fmt.Sprintf("Command finished successfully. %d artifacs were added to build info.", len(artifacts))) | ||
| return nil | ||
| } | ||
|
|
@@ -248,16 +240,16 @@ func (tc *TwineCommand) getRepoConfigFlagProvidedErr() string { | |
| return "twine command must not be executed with the following flags: " + coreutils.ListToText(twineRepoConfigFlags) | ||
| } | ||
|
|
||
| func CreateAqlQueryForSearch(repo, fileInitial string) string { | ||
| func CreateAqlQueryForSearchBySHA256(repo string, sha256s []string) string { | ||
| sha1Conditions := make([]string, len(sha256s)) | ||
| for i, sha256 := range sha256s { | ||
| sha1Conditions[i] = fmt.Sprintf(`{"sha256": "%s"}`, sha256) | ||
| } | ||
| sha256Condition := strings.Join(sha1Conditions, ",") | ||
| itemsPart := | ||
| `{` + | ||
| `"repo": "%s",` + | ||
| `"$or": [{` + | ||
| `"$and":[{` + | ||
| `"path": {"$match": "*"},` + | ||
| `"name": {"$match": "%s*"}` + | ||
| `}]` + | ||
| `}]` + | ||
| `"$or": [%s]` + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we using the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually it can more than one files to search.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense, it's not logical operator in aql, can we try and compare response for and vs or |
||
| `}` | ||
| return fmt.Sprintf(itemsPart, repo, fileInitial) | ||
| return fmt.Sprintf(itemsPart, repo, sha256Condition) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.