You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-11-06 09:09:19 +02:00
(feat) artifactPrepareVersion publish artifactid, group and package as cpe (#3100)
* release artifact, package and group to cpe * including versioning type as a cpe * unit test * eliminating versioningType Co-authored-by: Your Name <you@example.com>
This commit is contained in:
@@ -207,11 +207,12 @@ func runArtifactPrepareVersion(config *artifactPrepareVersionOptions, telemetryD
|
|||||||
commonPipelineEnvironment.git.commitMessage = gitCommitMessage
|
commonPipelineEnvironment.git.commitMessage = gitCommitMessage
|
||||||
|
|
||||||
// we may replace GetVersion() above with GetCoordinates() at some point ...
|
// we may replace GetVersion() above with GetCoordinates() at some point ...
|
||||||
if config.FetchCoordinates {
|
coordinates, err := artifact.GetCoordinates()
|
||||||
coordinates, err := artifact.GetCoordinates()
|
if err != nil && !config.FetchCoordinates {
|
||||||
if err != nil {
|
log.Entry().Warnf("fetchCoordinates is false and failed get artifact Coordinates")
|
||||||
return fmt.Errorf("failed to get coordinates: %w", err)
|
} else if err != nil && config.FetchCoordinates {
|
||||||
}
|
return fmt.Errorf("failed to get coordinates: %w", err)
|
||||||
|
} else {
|
||||||
commonPipelineEnvironment.artifactID = coordinates.ArtifactID
|
commonPipelineEnvironment.artifactID = coordinates.ArtifactID
|
||||||
commonPipelineEnvironment.groupID = coordinates.GroupID
|
commonPipelineEnvironment.groupID = coordinates.GroupID
|
||||||
commonPipelineEnvironment.packaging = coordinates.Packaging
|
commonPipelineEnvironment.packaging = coordinates.Packaging
|
||||||
|
|||||||
@@ -474,6 +474,33 @@ func TestRunArtifactPrepareVersion(t *testing.T) {
|
|||||||
|
|
||||||
assert.EqualError(t, err, "failed to get coordinates: coordinatesError")
|
assert.EqualError(t, err, "failed to get coordinates: coordinatesError")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("warning - failed to get coordinates", func(t *testing.T) {
|
||||||
|
config := artifactPrepareVersionOptions{
|
||||||
|
BuildTool: "maven",
|
||||||
|
VersioningType: "library",
|
||||||
|
FetchCoordinates: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
cpe := artifactPrepareVersionCommonPipelineEnvironment{}
|
||||||
|
|
||||||
|
versioningMock := artifactVersioningMock{
|
||||||
|
originalVersion: "1.2.3",
|
||||||
|
versioningScheme: "maven",
|
||||||
|
coordinatesError: fmt.Errorf("coordinatesError"),
|
||||||
|
}
|
||||||
|
|
||||||
|
worktree := gitWorktreeMock{
|
||||||
|
commitHash: plumbing.ComputeHash(plumbing.CommitObject, []byte{2, 3, 4}),
|
||||||
|
}
|
||||||
|
repo := gitRepositoryMock{
|
||||||
|
revisionHash: plumbing.ComputeHash(plumbing.CommitObject, []byte{1, 2, 3}),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := runArtifactPrepareVersion(&config, &telemetry.CustomData{}, &cpe, &versioningMock, nil, &repo, func(r gitRepository) (gitWorktree, error) { return &worktree, nil })
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVersioningTemplate(t *testing.T) {
|
func TestVersioningTemplate(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user