0

I am deploying jenkins with Git.

Almost process are fine, but can't build if project has .gitIgnore file.

Maven compiler can't recognize files that described on git ignore file.

But I need git ignore files because I should hide DB connection info and My authentication info on GitHub.

How can I config that?

wsha
  • 874
  • 2
  • 9
  • 25
  • what kind of java configuration are you using? spring? – JRichardsz Oct 02 '18 at 03:50
  • Welcome to Stackoverflow. Please add more details, like what files are you hiding. Does your build succeed locally without these files? – StephenKing Oct 02 '18 at 04:03
  • @JRichardsz I use Spring Framework in my projects. I want to resolve problem when deploying by Jenkins that maven didn't compile when project has .gitIgnore file. – Gi Deok Kim Oct 02 '18 at 04:50
  • @StephenKing Yes, All build and deploy procedure is fine if not contains git Ignore file. Maven compiler can't see classes that adapted git ignore option. It is occured when maven building. – Gi Deok Kim Oct 02 '18 at 04:55
  • @GiDeokKim are you using spring boot or some previous version of spring framework? – JRichardsz Oct 02 '18 at 13:55

1 Answers1

0

If you are using spring framework, all of your concerns are solved.

Spring allows you to use:

  • local properties
  • properties file from others jars
  • properties file located in any directory of operative system

If you like to code, you can write your own PropertyPlaceholderConfigurer to read your properties file from where you want, for example from database :

https://www.opencodez.com/java/how-to-load-application-properties-from-database.htm

Also you can check this link to analyze others approaches to externalize your properties file, not only for java frameworks:

https://stackoverflow.com/a/51268633/3957754

JRichardsz
  • 14,356
  • 6
  • 59
  • 94
  • Thanks a lot!! I solved it following your advice. I made properties file in my EC2 instance and load conf info when project package loaded. But properties file path show in gitHub. Do you know to how hide it clearly on gitHub? – Gi Deok Kim Oct 05 '18 at 03:05
  • @GiDeokKim if this was useful and/or was the solution to your problem, please give my like and check this answer as solved :D – JRichardsz Oct 05 '18 at 17:27
  • @GiDeokKim in order to hide sensitive values, you could use jenkins environment vars. Are you using pipelines, plugins or shell executions? – JRichardsz Oct 05 '18 at 17:30
  • I will try to solve this problem using Jenkins pipeline. I will to do click 'like' flag for you after add 15 reputations. Thanks for your reply! – Gi Deok Kim Oct 10 '18 at 03:45