We have created a sqlhost file in gitrepo along with dockerfile, kubernetes yaml file and jenkinsfile,each time I have to manually add entry in sqlhost file which later dockerfile takes the value from sqlhost Is there a way from jenkins which can pass value as a parameter to dockefile and then build dockefile
You can use an ARG or an ENV instruction to specify variables that are needed to be available to the Dockerfile
ARG: Sample dockerfile
FROM ubuntu
ARG SQLHOST Here you can see the SQLHOST Argument is provided in dockerfile, and while buiding specify as
$ docker build --build-arg SQLHOST=prod-vm.example.com .also you can use specify same in Jenkins configuration.
ENV: Sample dockerfile
FROM ubuntu
ENV SQLHOST defaultHostHere you can see the SQLHOST Environment variable is provided in dockerfile, and while buiding specify as
$ set SQLHOST=prod-vm.example.com; docker build .also you can use specify same in Jenkins configuration.
Did you try ARG? Please refer this documentation for more details.