Grails WAR file version - grails

I would like to printout the grails war file version on my main page template, so when I deploy a WAR file, it become easy to recognize which version of the app is running on which server and so on.
Where to set it and how to print it out in a gsp tag?

There's a tag you can use as a short cut
<g:meta name="app.version"/>
You can set it using
grails set-version someVersionHere

I figured out how to display it but still don't know how to set it except by changing it in the application.properties
ApplicationName Version: ${grailsApplication.metadata['app.version']} Built by grailsApplication.metadata['app.grails.version']
I guess its the only way!!

To answer your question of SETTING the VERSION:
For example building with Jenkins or Hudson will automatically set the build number and CVS revision number to your war.
Using that sort of build tool + the Build Info plugin is a good way to achieve visibility to which version of your site you are running.
Of course setting up Jenkins takes some effort, but the it is a one-time cost and then you will just have button "Build Now" that will take care of it and you can optionally also configure deployment tasks to upload it automatically as well... but now I've drifted slightly off-topic.

Related

Could not set proper JBOSS_HOME directory in Jenkins

I'm just starting with Jenkins. I'm trying to set JBoss Management Builder (unless I do not need this plugin to control deployment on WildFly?) and Jenkins do not want to accept my JBOSS_HOME dir.
My home dir is:
/home/opt/wildfly-10.1.0.Final/
I have also tried:
/home/opt/wildfly-10.1.0.Final/bin/
/home/opt/wildfly-10.1.0.Final/standalone/
/home/opt/wildfly-10.1.0.Final/standalone/configuration/
/home/opt/wildfly-10.1.0.Final/standalone/configuration/standalone.xml
All of this tries have ended with an error:
"It's not look like correct JBoss home directory"
I think it's unlikely that the JBoss Management Builder plugin will work with Wildfly.
Its latest release is from 2011 as written on the plugin page. Plus the source code where the error is coming from is looking for two folders explicitly in your JBOSS_HOME: "bin" and "server". And "server" is just not there in Wildfly.
I think you have to find other ways to interact with Wildfly.

Post Deployment JVM log validation for JBOSS and WAS Application

We use Jenkins and Urban Code Deploy to do our builds and deployments respectively. Post the deployment we manually go ahead and validate the JVM logs. Most of the Applications we deploy are JBOSS and WAS8.5. I wanted some suggestion on automating this post deployment validation task. Is there any tool, plugin that can be integrated with Urban Code Deploy to perform this log parsing against certain keywords.
I have "Log parser" plugin which is an open source plugin in Jenkins. Are there any better ideas?
In UrbanCode Deploy you can use the step called "Monitor File Contents" to check if a regular expression is contained in a file.
Another way would be to output the log file content in a shell step, like cat logfile, and then use a post-processing script to check if an expression is in the file. In this case, you can use JavaScript syntax. See

ThymeLeaf with Grails 2.4

Is it possible to use ThymeLeaf with Grails 2.4?
There is a plugin that was started (https://grails.org/plugins/pending/250), but it doesn't appear to be active anymore and it noted some significant issues.
I've done quite a bit of searching and haven't been able to find anything on this subject other than the abandoned plugin... maybe I should take that as a sign.
Try it out and see. Clone the repo, then edit ThymeleafGrailsPlugin.groovy and change the version to a -SNAPSHOT version:
def version = "0.1-SNAPSHOT"
Then run grails compile and grails maven-install. That second script will build the plugin and copy it to your local Maven cache in the same format as if it were retrieved as a published plugin.
To use it in a project, add it like any released plugin, e.g.
compile ':thymeleaf:0.1-SNAPSHOT'
and it will resolve from your Maven cache.
To make changes, leave the version but run clean and maven-install again, but delete the plugin directory in the cache. That'll be something like $HOME/.m2/repository/org/grails/plugins/thymeleaf/0.1-SNAPSHOT - delete the whole directory, and after rebuilding the new version will be used.
David's email is in ThymeleafGrailsPlugin.groovy if you get stuck. It's easy to miss comments in the plugin proposal pages, so don't take a lack of a reply there as an indication that the plugin is totally abandoned.

How to set version for grails application when deployed

insted of using
grails> set-version
command, is there any possible ways to generate application version when deployed itself.
You can set it by changing app.version in application.properties (at the project base directory).
I'm not completely clear what you mean by "when deployed", but you could change the version programmatically during your build (by editing the file), if that's what you're asking.
Once the application is packaged up into a war and deployed, changing the version would be tougher. You can rename the war (to not include the version), if that's what you're concerned about.
The app version is static; the set-version script simply updates the version number in application.properties. The version is a build-time property, it's not something that you would change at deployment time.
I'm not sure why you would want to change a version number during deployment. From a configuration management perspective build numbers are usually part of the build itself and don't ever change until there is another build.
I was able to achieve this (grails 3.3.0) by setting the version parameter in build.gradle file of the application
version "0.2"

Set a different classpath for just one grails command

I need to set a different classpath for one single grails xxx command.
The point is that my application uses latest version of commons-httpclient. I have no problems with this. But after building my application I need to use grails maven-deploy to store my war file in a webdav repository, and the command conflicts with the latest version of commons-httpclient. This command works great if I add commons-httpclient-2.0.2.jar in the classpath (lib folder for example), but the app will fail on trying to use the regular features that depends on commons-httpclient.
I need to add this other jar in the classpath just for running the maven-deploy command, any ideas?
I'm using jenkins (huson) to build the app, so, any tips on making the solution achievable with grails jenkins plugins will be appreciated.
Thanks a lot,
Does the grails maven-deploy command conflicts due to another dependency on httpclient?
Which one is it? May be you could exclude the dependency it?

Resources