1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-02-11 13:53:53 +02:00
sap-jenkins-library/cmd/mavenExecute.go
Pavel Busko 98e4e01635
feat(cnbBuild): warn users when dockerConfigJSON is missing necessary credentials (#5007)
* feat(cnbBuild): warn users when dockerConfigJSON is missing necessary credentials

* Update cmd/cnbBuild.go

Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>

* Update pkg/cnbutils/auth.go

Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>

* fix linting

---------

Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
2024-08-15 10:20:01 +02:00

63 lines
1.7 KiB
Go

package cmd
import (
"os"
"github.com/SAP/jenkins-library/pkg/command"
piperhttp "github.com/SAP/jenkins-library/pkg/http"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/maven"
"github.com/SAP/jenkins-library/pkg/piperutils"
"github.com/SAP/jenkins-library/pkg/telemetry"
)
type mavenExecuteUtils interface {
maven.Utils
FileWrite(path string, content []byte, perm os.FileMode) error
}
type mavenExecuteUtilsBundle struct {
*command.Command
*piperutils.Files
*piperhttp.Client
}
func newMavenExecuteUtilsBundle() mavenExecuteUtils {
utils := mavenExecuteUtilsBundle{
Command: &command.Command{},
Files: &piperutils.Files{},
Client: &piperhttp.Client{},
}
utils.Stdout(log.Writer())
utils.Stderr(log.Writer())
return &utils
}
func mavenExecute(config mavenExecuteOptions, _ *telemetry.CustomData) {
err := runMavenExecute(config, newMavenExecuteUtilsBundle())
if err != nil {
log.Entry().WithError(err).Fatal("step execution failed")
}
}
func runMavenExecute(config mavenExecuteOptions, utils mavenExecuteUtils) error {
options := maven.ExecuteOptions{
PomPath: config.PomPath,
ProjectSettingsFile: config.ProjectSettingsFile,
GlobalSettingsFile: config.GlobalSettingsFile,
M2Path: config.M2Path,
Goals: config.Goals,
Defines: config.Defines,
Flags: config.Flags,
LogSuccessfulMavenTransfers: config.LogSuccessfulMavenTransfers,
ReturnStdout: config.ReturnStdout,
}
output, err := maven.Execute(&options, utils)
if err == nil && config.ReturnStdout {
err = utils.FileWrite(".pipeline/maven_output.txt", []byte(output), 0644)
}
return err
}