J’ai donc l’extrait de code suivant:
def getVersion = { -> def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'describe', '--tags' standardOutput = stdout } return stdout.toSsortingng().sortingm() }
et chaque fois que j’appelle getVersion()
, j’obtiens l’erreur suivante:
* What went wrong: A problem occurred evaluating root project 'ForgeWorkspace'. > Process 'command 'git'' finished with non-zero exit value 128 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 6.442 secs
Sur mon MacBook Pro, je n’ai jamais rencontré ce problème, mais sur Windows. Toute aide est grandement appréciée!
@RaGe est presque correct. Comme vous devez en effet utiliser l’invite de commande Windows (cmd) pour que le système d’exploitation recherche l’exécutable git dans le chemin d’access du système, la commande git entière doit être transmise comme un argument qui suit le commutateur /c
.
Donc, ce qui suit devrait fonctionner:
commandLine 'cmd', '/c', 'git describe --tags'
Sur windows, les deux premiers arguments de commandLine
devraient être cmd et / c
//on windows: commandLine 'cmd', '/c', 'git'...
Voir ici