1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-10-30 23:57:50 +02:00

Use absolute path for m2path in mta install (#1671)

This commit is contained in:
Florian Wilhelm
2020-06-16 09:48:47 +02:00
committed by GitHub
parent 9a30758115
commit b0329cd2c0
4 changed files with 22 additions and 9 deletions

View File

@@ -44,7 +44,8 @@ apt-get -yqq update; apt-get -yqq install make
curl -OL https://github.com/SAP/cloud-mta-build-tool/releases/download/v1.0.14/cloud-mta-build-tool_1.0.14_Linux_amd64.tar.gz
tar xzf cloud-mta-build-tool_1.0.14_Linux_amd64.tar.gz
mv mbt /usr/bin
/piperbin/piper mtaBuild >test-log.txt 2>&1
mkdir mym2
/piperbin/piper mtaBuild --m2Path=mym2 >test-log.txt 2>&1
`
ioutil.WriteFile(filepath.Join(tempDir, "runPiper.sh"), []byte(testScript), 0700)
@@ -75,9 +76,9 @@ mv mbt /usr/bin
t.Fatal("Could not read test-log.txt.", err)
}
output := string(content)
assert.Contains(t, output, "Installing /test/pom.xml to /root/.m2/repository/mygroup/mymvn/1.0-SNAPSHOT/mymvn-1.0-SNAPSHOT.pom")
assert.Contains(t, output, "Installing /test/app/target/mymvn-app-1.0-SNAPSHOT.war to /root/.m2/repository/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT.war")
assert.Contains(t, output, "Installing /test/app/target/mymvn-app-1.0-SNAPSHOT-classes.jar to /root/.m2/repository/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT-classes.jar")
assert.Contains(t, output, "Installing /test/pom.xml to /test/mym2/mygroup/mymvn/1.0-SNAPSHOT/mymvn-1.0-SNAPSHOT.pom")
assert.Contains(t, output, "Installing /test/app/target/mymvn-app-1.0-SNAPSHOT.war to /test/mym2/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT.war")
assert.Contains(t, output, "Installing /test/app/target/mymvn-app-1.0-SNAPSHOT-classes.jar to /test/mym2/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT-classes.jar")
}
func TestNPMProject(t *testing.T) {

View File

@@ -4,3 +4,4 @@ mtaBuild_errorDetails.json
foo.mtar
.flattened-pom.xml
.pipeline/
mym2

View File

@@ -3,11 +3,13 @@
set -e
set -x
mkdir mym2
cd /project
/piper mtaBuild
/piper mtaBuild --m2Path=mym2
find /root/.m2/repository/mygroup
find /project/mym2
[ -f /root/.m2/repository/mygroup/mymvn/1.0-SNAPSHOT/mymvn-1.0-SNAPSHOT.pom ] || (echo "Assertion failed, file mymvn-1.0-SNAPSHOT.pom must exist"; exit 1)
[ -f /root/.m2/repository/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT.war ] || (echo "Assertion failed, file mymvn-app-1.0-SNAPSHOT.war must exist"; exit 1)
[ -f /root/.m2/repository/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT-classes.jar ] || (echo "Assertion failed, file mymvn-app-1.0-SNAPSHOT-classes.jar must exist"; exit 1)
[ -f /project/mym2/mygroup/mymvn/1.0-SNAPSHOT/mymvn-1.0-SNAPSHOT.pom ] || (echo "Assertion failed, file mymvn-1.0-SNAPSHOT.pom must exist"; exit 1)
[ -f /project/mym2/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT.war ] || (echo "Assertion failed, file mymvn-app-1.0-SNAPSHOT.war must exist"; exit 1)
[ -f /project/mym2/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT-classes.jar ] || (echo "Assertion failed, file mymvn-app-1.0-SNAPSHOT-classes.jar must exist"; exit 1)

View File

@@ -167,6 +167,15 @@ func doInstallMavenArtifacts(command mavenExecRunner, options EvaluateOptions, u
return err
}
// Ensure m2 path is an absolute path, even if it is given relative
// This is important to avoid getting multiple m2 directories in a maven multimodule project
if options.M2Path != "" {
options.M2Path, err = filepath.Abs(options.M2Path)
if err != nil {
return err
}
}
// Set pom path fix here because we will change into the respective pom's directory
options.PomPath = "pom.xml"
for _, pomFile := range pomFiles {