2020-02-28 14:09:46 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/SAP/jenkins-library/pkg/command"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/log"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/maven"
|
2020-04-24 10:41:49 +02:00
|
|
|
"io/ioutil"
|
2020-02-28 14:09:46 +02:00
|
|
|
|
|
|
|
"github.com/SAP/jenkins-library/pkg/telemetry"
|
|
|
|
)
|
|
|
|
|
2020-05-06 17:43:32 +02:00
|
|
|
var writeFile = ioutil.WriteFile
|
|
|
|
|
2020-04-24 10:41:49 +02:00
|
|
|
func mavenExecute(config mavenExecuteOptions, _ *telemetry.CustomData) {
|
|
|
|
runner := command.Command{}
|
|
|
|
err := runMavenExecute(config, &runner)
|
|
|
|
if err != nil {
|
|
|
|
log.Entry().WithError(err).Fatal("step execution failed")
|
|
|
|
}
|
|
|
|
}
|
2020-02-28 14:09:46 +02:00
|
|
|
|
2020-07-01 11:28:16 +02:00
|
|
|
func runMavenExecute(config mavenExecuteOptions, runner command.ExecRunner) error {
|
2020-02-28 14:09:46 +02:00
|
|
|
options := maven.ExecuteOptions{
|
|
|
|
PomPath: config.PomPath,
|
|
|
|
ProjectSettingsFile: config.ProjectSettingsFile,
|
|
|
|
GlobalSettingsFile: config.GlobalSettingsFile,
|
|
|
|
M2Path: config.M2Path,
|
2020-05-06 17:43:32 +02:00
|
|
|
Goals: config.Goals,
|
|
|
|
Defines: config.Defines,
|
|
|
|
Flags: config.Flags,
|
2020-02-28 14:09:46 +02:00
|
|
|
LogSuccessfulMavenTransfers: config.LogSuccessfulMavenTransfers,
|
|
|
|
ReturnStdout: config.ReturnStdout,
|
|
|
|
}
|
|
|
|
|
2020-04-24 10:41:49 +02:00
|
|
|
output, err := maven.Execute(&options, runner)
|
|
|
|
if err == nil && config.ReturnStdout {
|
2020-05-06 17:43:32 +02:00
|
|
|
err = writeFile(".pipeline/maven_output.txt", []byte(output), 0644)
|
2020-02-28 14:09:46 +02:00
|
|
|
}
|
2020-04-24 10:41:49 +02:00
|
|
|
return err
|
|
|
|
}
|