mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Golang build publish binaries and add group id (#3749)
* Add golang binaries to CPE and add groupID in coordinates Signed-off-by: Ashly Mathew <ashly.mathew@sap.com> * Introducing binaries as artifacts Signed-off-by: Ashly Mathew <ashly.mathew@sap.com>
This commit is contained in:
parent
fe9b3a796b
commit
823ef47db6
@ -259,7 +259,9 @@ func runGolangBuild(config *golangBuildOptions, telemetryData *telemetry.CustomD
|
||||
|
||||
utils.SetOptions(repoClientOptions)
|
||||
|
||||
var binaryArtifacts piperenv.Artifacts
|
||||
for _, binary := range binaries {
|
||||
|
||||
targetPath := fmt.Sprintf("go/%s/%s/%s", goModFile.Module.Mod.Path, config.ArtifactVersion, binary)
|
||||
|
||||
separator := "/"
|
||||
@ -281,7 +283,13 @@ func runGolangBuild(config *golangBuildOptions, telemetryData *telemetry.CustomD
|
||||
if !(response.StatusCode == 200 || response.StatusCode == 201) {
|
||||
return fmt.Errorf("couldn't upload artifact, received status code %d", response.StatusCode)
|
||||
}
|
||||
|
||||
binaryArtifacts = append(binaryArtifacts, piperenv.Artifact{
|
||||
Name: binary,
|
||||
})
|
||||
}
|
||||
commonPipelineEnvironment.artifacts = binaryArtifacts
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -48,7 +48,8 @@ type golangBuildOptions struct {
|
||||
}
|
||||
|
||||
type golangBuildCommonPipelineEnvironment struct {
|
||||
custom struct {
|
||||
artifacts piperenv.Artifacts
|
||||
custom struct {
|
||||
buildSettingsInfo string
|
||||
}
|
||||
}
|
||||
@ -60,6 +61,7 @@ func (p *golangBuildCommonPipelineEnvironment) persist(path, resourceName string
|
||||
value interface{}
|
||||
}{
|
||||
{category: "custom", name: "buildSettingsInfo", value: p.custom.buildSettingsInfo},
|
||||
{category: "", name: "artifacts", value: p.artifacts},
|
||||
}
|
||||
|
||||
errCount := 0
|
||||
@ -526,6 +528,7 @@ func golangBuildMetadata() config.StepData {
|
||||
Type: "piperEnvironment",
|
||||
Parameters: []map[string]interface{}{
|
||||
{"name": "custom/buildSettingsInfo"},
|
||||
{"name": "artifacts", "type": "piperenv.Artifacts"},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -96,6 +96,11 @@ func (m *GoMod) GetCoordinates() (Coordinates, error) {
|
||||
artifactSplit := strings.Split(parsed.Module.Mod.Path, "/")
|
||||
artifactID := artifactSplit[len(artifactSplit)-1]
|
||||
result.ArtifactID = artifactID
|
||||
|
||||
goModPath := parsed.Module.Mod.Path
|
||||
lastIndex := strings.LastIndex(goModPath, "/")
|
||||
groupID := goModPath[0:lastIndex]
|
||||
result.GroupID = groupID
|
||||
}
|
||||
result.Version = parsed.Module.Mod.Version
|
||||
if result.Version == "" {
|
||||
|
@ -240,6 +240,8 @@ spec:
|
||||
type: piperEnvironment
|
||||
params:
|
||||
- name: custom/buildSettingsInfo
|
||||
- name: artifacts
|
||||
type: "piperenv.Artifacts"
|
||||
- name: reports
|
||||
type: reports
|
||||
params:
|
||||
|
Loading…
Reference in New Issue
Block a user