0

When running "war" command from Grails, I want to store the build commit for use it in a GSP thereafter.

In my Config.groovy

def proc = 'git rev-parse HEAD'.execute() proc.waitFor() build_commit.number = proc.in.text

In my GSP

<p>${grailsApplication.config.build_commit.number}</p>

Everything work fine when I run my app with "run app" command but when I deploy my War on Tomcat the information is no longer available.

Is it because Config.groovy is reevaluate when the war is deploy ?

I also try to write programmatically the build commit to application.properties but I couldn't find a way to do that.. If it's possible, I also need to know how to detect a Tomcat env for avoid rewriting a blank value.

Any help will be appreciate.

el_gars
  • 11
  • 2

1 Answers1

0

If you need persistent data (like your build_commit.number) you should investigate integrating your application with a database, or writing this to a file on your filesystem. Either one will require access from both your development environment (where you run "run app") and your production environment (where you deploy the war to tomcat).

Daniel
  • 3,312
  • 1
  • 14
  • 31
  • Store this information to DB is not a solution for me. I could write this to a file but it seems that when Config.groovy is call I can't use classLoader to retrieve my file.. I created a file in conf folder of my grails project and tryed to get it with: `this.class.classLoader.getResource('build_commit.txt')` – el_gars Dec 10 '18 at 13:29