Reputation: 3050
fedora 33, git install at /usr/bin/git
, and it is added in PATH
.
In build.gradle file, I have extract the git hash to use it later on in building the docker image tag.
def dockerImageVersion = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git describe --first-parent --abbrev=10 --long --dirty"
standardOutput = stdout
}
return stdout.toString().trim()
}
jib {
from {
image = 'adoptopenjdk/openjdk11:ubi-minimal-jre'
}
to {
image = "napa/activity-service"
tags = ["${dockerImageVersion}", "latest"]
}
container {
mainClass = "com.regrexx.user.events.InteractionEventsSinkVerticle"
jvmFlags = ["-noverify", "-Djava.security.egd=file:/dev/./urandom"]
user = "nobody:nobody"
}
}
It gives error: Cause: error=2, No such file or directory
Even after I changed the command to be something commandLine 'echo hello'
, I still get the same error.
Upvotes: 0
Views: 1098
Reputation: 193696
commandLine
is expecting a List<String>
and not a whitespaced separated String.
In other words, Gradle is looking for a file in your PATH matching the whole string. It is not parsing the spaces to separate the command and arguments. It is expecting that to be done already.
Try:
commandLine "git", "describe", "--first-parent", "--abbrev=10", "--long", "--dirty"
Upvotes: 2