mjhugo / grails-build-info

Provides a Grails controller/view that display basic information about a deployed WAR file
Other
8 stars 14 forks source link

GIT_BRANCH, GIT_COMMIT not populated in application.properties #8

Closed kyleboon closed 2 years ago

kyleboon commented 11 years ago

I'm not sure how our jenkins build is different, but we don't get the GIT_BRANCH, GIT_COMMIT and a few other envrionment variables set in the application.properties file when the war is built. I worked around the issue with the following in _Events.groovy:

entry(key: 'Built-By', value: System.getProperty('user.name'))
entry(key: 'Build-Jdk', value: System.getProperty('java.version'))
entry(key: 'BUILD_NUMBER', value: System.getenv('BUILD_NUMBER') ?: 'LOCAL')
entry(key: 'BUILD_URL', value: System.getenv('BUILD_URL') ?: 'LOCAL')
entry(key: 'GIT_COMMIT', value: System.getenv('GIT_COMMIT') ?: 'LOCAL')
entry(key: 'GIT_BRANCH', value: System.getenv('GIT_BRANCH') ?: 'LOCAL')

I'd be happy to make a pull request to add this into the plugin but since I'm not sure why I need to do this, it makes me slightly uncomfortable.

rlovtangen commented 10 years ago

Hi kyleboon. Since being added as a developer, I haven't really looked into all the details for this. But environment variables should be added to application.properties with the prefix 'environment'. E.g. environment.GIT_COMMIT. What you are saying is that it doesn't happen with your jenkins build?

kyleboon commented 10 years ago

@rlovtangen correct, I do get a bit list of 'environment' properties added to application.properties but nothing for GIT_COMMIT or GIT_BRANCH. I can paste the whole list in here if you want.

rlovtangen commented 10 years ago

Ok, I see. The thing is that all 'environment' properties are written to application.properties, which means that probably 'environment.GIT_COMMIT' for some reason is not part of Ant.antProject.properties on your jenkins.

Yes, please post the whole list, make sure to mask any environment variables you don't want to publish to the internet, if any. (I already have a fix in my local repo that writes only selected environment variables to application.properties, see issue #5, but I need to work out some issues wrt a catch-22 with compilation before pushing).