I have a Gradle build file, where one of the tasks is to enter docker. In this task, I want the user / CI to provide docker_username, docker_password and docker_email parameters.
task loginDockerHub(group: "Docker", type:Exec) { executable "docker" args "login","-u", docker_username, "-p", docker_password, "-e", docker_email }
Doing gradle loginDockerHub -Pdocker_username=vad1mo ... works as expected.
But when I execute, for example, gradle build , I get an error:
Could not find property 'docker_username' on task ': loginDockerHub'.
I would expect this error when doing gradle loginDockerHub without providing the -P option, but not for other tasks that don't have access to docker_username / password options.
How can I have optional parameters for my loginDockerHub task in Gradle that do not make the parameter mandatory for any other task.
build.gradle gradle
Vadimo
source share