récupération de param et execution de commandes
Bonjour j'ai un batch dont je ne comprends pas le comportement
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| @REM Script de récupération d'artifact.
@ECHO ON
if "%1" == "" (echo usage: %0 groupId artefactId version [type [classifier]]) else (
set groupId=%1
set artifactId=%2
set version=%3
if "%4" == "" (set typeFile=jar) else (set typeFile=%4)
if "%5" == "" (set classifier=) else (set classifier=-Dclassifier=%5)
set destinationJar=%~dp0%artifactId%-%version%.%typeFile%
echo %classifier%
rem mvn help:effective-pom -Paphp-dev-livraison -f %~dp0\CopyArtifact.pom
echo Récupération du %typeFile% %artifactId%-%version%
call mvn dependency:get -q -f %~dp0\CopyArtifact.pom -Paphp-dev-livraison -DgroupId=%groupId% -DartifactId=%artifactId% -Dversion=%version% -Ddest=%destinationJar% -Dpackaging=%typeFile% -Dtransitive=false %classifier%
echo Installation sur le repo %typeFile%
call mvn deploy:deploy-file -q -f %~dp0\CopyArtifact.pom -Paphp-dev-livraison -DrepositoryId=${deploymentRepositoryId} -Durl=${deployementRepositoryUrl} -Dfile=%destinationJar% -DgroupId=%groupId% -DartifactId=%artifactId% -Dversion=%version% -Dpackaging=%typeFile% -DgeneratePom=false %classifier%
rm -R %~dp0%artifactId%-%version%.%typeFile%
) |
mon problème se situe aux lignes 17 et 20 et concerne la variable destinationJar
si j'exécute une première fois mon script ainsi
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| D:\Travail\Olympe\temp>CopyArtifact fr.aphp.ati.eai.hermes ng484-ageps-out 1.0.0
D:\Travail\Olympe\temp>SETLOCAL
D:\Travail\Olympe\temp>if "fr.aphp.ati.eai.hermes" == "" (echo usage: CopyArtifact groupId artefactId version [type [classifier]] ) else (
set groupId=fr.aphp.ati.eai.hermes
set artifactId=ng484-ageps-out
set version=1.0.0
if "" == "" (set typeFile=jar ) else (set typeFile= )
if "" == "" (set classifier= ) else (set classifier=-Dclassifier= )
set destinationJar=D:\tools\org\apache\maven\3.0.3\bin\-.
echo
rem mvn help:effective-pom -Paphp-dev-livraison -f D:\tools\org\apache\maven\3.0.3\bin\\CopyArtifact.pom
echo Récupération du -
call mvn dependency:get -q -f D:\tools\org\apache\maven\3.0.3\bin\\CopyArtifact.pom -Paphp-dev-livraison -DgroupId= -DartifactId= -Dversion= -Ddest= -Dpackaging= -Dtransitive=false
echo Installation sur le repo
call mvn deploy:deploy-file -q -f D:\tools\org\apache\maven\3.0.3\bin\\CopyArtifact.pom -Paphp-dev-livraison -DrepositoryId=${deploymentRepositoryId} -Durl=${deployementRepositoryUrl} -Dfile= -DgroupId= -DartifactId= -Dversion= -Dpackaging= -DgeneratePom=false
rm -R D:\tools\org\apache\maven\3.0.3\bin\-.
)
Commande ECHO activée.
Récupération du -
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.4:get (default-cli) on project copy-artifact: Execution default-cli of goal org... |
Je constate dans la trace qu'il fait bien un set
de groupId artifactId et version mais juste après lorsque qu'il fait set destinationJar=%~dp0%artifactId%-%version%.%typeFile%ni %artifactId% n i%version% ne sont substitués
le reste de l'exécution a le même comportement.
si j'appelle le même script j'ai cette fois
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| D:\Travail\Olympe\temp>CopyArtifact fr.aphp.ati.eai.hermes ng484-ageps-out 1.0.0
D:\Travail\Olympe\temp>if "fr.aphp.ati.eai.hermes" == "" (echo usage: CopyArtifact groupId artefactId version [type [classifier]] ) else (
set groupId=fr.aphp.ati.eai.hermes
set artifactId=ng484-ageps-out
set version=1.0.0
if "" == "" (set typeFile=jar ) else (set typeFile= )
if "" == "" (set classifier= ) else (set classifier=-Dclassifier= )
set destinationJar=D:\tools\org\apache\maven\3.0.3\bin\ng484-ageps-out-1.0.0.jar
echo
rem mvn help:effective-pom -Paphp-dev-livraison -f D:\tools\org\apache\maven\3.0.3\bin\\CopyArtifact.pom
echo Récupération du jar ng484-ageps-out-1.0.0
call mvn dependency:get -q -f D:\tools\org\apache\maven\3.0.3\bin\\CopyArtifact.pom -Paphp-dev-livraison -DgroupId=fr.aphp.ati.eai.hermes -DartifactId=ng484-ageps-out -Dversion=1.0.0 -Ddest=D:\tools\org\apache\maven\3.0.3\bin\-. -Dpackaging=jar -Dtransitive=false
echo Installation sur le repo jar
call mvn deploy:deploy-file -q -f D:\tools\org\apache\maven\3.0.3\bin\\CopyArtifact.pom -Paphp-dev-livraison -DrepositoryId=${deploymentRepositoryId} -Durl=${deployementRepositoryUrl} -Dfile=D:\tools\org\apache\maven\3.0.3\bin\-. -DgroupId=fr.aphp.ati.eai.hermes -DartifactId=ng484-ageps-out -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=false
rm -R D:\tools\org\apache\maven\3.0.3\bin\ng484-ageps-out-1.0.0.jar
)
Commande ECHO activée.
Récupération du jar ng484-ageps-out-1.0.0
Installation sur le repo jar
rm: cannot unlink entry "D:/tools/org/apache/maven/3.0.3/bin/ng484-ageps-out-1.0.0.jar": Le fichier spécifié est introuvable. |
cette fois destinationJar reçois la bonne valeur mais elle n'est pas utilisé par la suite l'appel suivant avec des paramètres différents donne
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| D:\Travail\Olympe\temp>CopyArtifact fr.aphp.ati.eai.hermes ng484-hegp-out 1.0.0
D:\Travail\Olympe\temp>if "fr.aphp.ati.eai.hermes" == "" (echo usage: CopyArtifact groupId artefactId version [type [classifier]] ) else (
set groupId=fr.aphp.ati.eai.hermes
set artifactId=ng484-hegp-out
set version=1.0.0
if "" == "" (set typeFile=jar ) else (set typeFile= )
if "" == "" (set classifier= ) else (set classifier=-Dclassifier= )
set destinationJar=D:\tools\org\apache\maven\3.0.3\bin\ng484-ageps-out-1.0.0.jar
echo
rem mvn help:effective-pom -Paphp-dev-livraison -f D:\tools\org\apache\maven\3.0.3\bin\\CopyArtifact.pom
echo Récupération du jar ng484-ageps-out-1.0.0
call mvn dependency:get -q -f D:\tools\org\apache\maven\3.0.3\bin\\CopyArtifact.pom -Paphp-dev-livraison -DgroupId=fr.aphp.ati.eai.hermes -DartifactId=ng484-ageps-out -Dversion=1.0.0 -Ddest=D:\tools\org\apache\maven\3.0.3\bin\ng484-ageps-out-1.0.0.jar -Dpackaging=jar -Dtransitive=false
echo Installation sur le repo jar
call mvn deploy:deploy-file -q -f D:\tools\org\apache\maven\3.0.3\bin\\CopyArtifact.pom -Paphp-dev-livraison -DrepositoryId=${deploymentRepositoryId} -Durl=${deployementRepositoryUrl} -Dfile=D:\tools\org\apache\maven\3.0.3\bin\ng484-ageps-out-1.0.0.jar -DgroupId=fr.aphp.ati.eai.hermes -DartifactId=ng484-ageps-out -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=false
rm -R D:\tools\org\apache\maven\3.0.3\bin\ng484-ageps-out-1.0.0.jar
)
Commande ECHO activée.
Récupération du jar ng484-ageps-out-1.0.0
Installation sur le repo jar
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy-file (default-cli) on project copy-artifact: Failed to deploy artifacts: Could not transfer artifact fr.aphp.ati.eai.hermes:ng484-ageps-out:jar:1.0.0 from/to qualif (http://sap-nexus.sap.aphp.fr:8081/nexus/content/repositories/qualif/): Access denied to: http://sap-nexus.sap.aphp.fr:8081/nexus/content/repositories/qualif/fr/aphp/ati/eai/hermes/ng484-ageps-out/1.0.0/ng484-ageps-out-1.0.0.jar - |
cette fois la variable artifactId reçoi la bonne valeur mais destinationJar est construit avec les valeur de l'appel précédent et
c'est cette valeur qui est utilisé.
Je suis preneur de toutes suggestion car je ne connais pas bien le DOS
Merci à tous
A+JYT