title: How can I get jenkins build number, svn revision number... and display it on my JSF page?
body: <p>I have a JSF, Spring, Hibernate project.
  At the bottom of a page I have to have version number.
  Using jenkins(hudson) I have installed "Parameterized Build" . But it seems it is not working. How can I get jenkins build number, maven project version, svn revision number and display it on my JSF page?</p>
  
  <p>I couldn't find a useful example on the web. </p>
  
  <p>Thanks</p>
  
  <p>main/resources/com/example/build.properties</p>
  
  <pre><code>custom_version  = Test 1.0
  pom_version     = ${pom_version}
  svn_revision    = ${svn_revision}
  build_tag       = ${build_tag}
  build_number    = ${build_number}
  build_id        = ${build_id}
  </code></pre>
  
  <p>faces-config.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"&gt;
  
      &lt;application&gt;
          &lt;resource-bundle&gt;
              &lt;base-name&gt;com.example.build&lt;/base-name&gt;
              &lt;var&gt;build&lt;/var&gt;
          &lt;/resource-bundle&gt;
      &lt;/application&gt;
  
  &lt;/faces-config&gt;
  </code></pre>
  
  <p>version.xhtml</p>
  
  <pre><code>&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      &gt;
      &lt;center&gt;
  
          &lt;p&gt;Version:  #{build['custom_version']}.#{build['build_tag']}.#{build['build_number']}.#{build['build_id']}.#{build['svn_revision']}&lt;/p&gt;
  
      &lt;/center&gt;
  
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p><strong>Here is my working solution:</strong></p>
  
  <p>main/resources/com/example/build.properties</p>
  
  <pre><code>custom_version  = ${env.CUSTOM_VERSION}
  custom_message  = ${env.CUSTOM_MESSAGE}
  
  pom_version     = ${pom.version}
  pom_name        = ${pom.name}
  pom_description = ${pom.description}
  
  svn_revision    = ${env.SVN_REVISION}
  build_tag       = ${env.JOB_NAME}
  build_number    = ${env.BUILD_NUMBER}
  build_id        = ${env.BUILD_ID}
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.example&lt;/groupId&gt;
      &lt;artifactId&gt;jenkins_build_deploy&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;name&gt;jenkins_build_deploy&lt;/name&gt;
      &lt;description&gt;jenkins_build_deploy application&lt;/description&gt;
      &lt;url&gt;http://example.com/jenkins_build_deploy&lt;/url&gt;
  
      &lt;scm&gt;
          &lt;url&gt;http://127.0.0.1/dummy&lt;/url&gt;
          &lt;connection&gt;scm:svn:http://127.0.0.1/dummy&lt;/connection&gt;
          &lt;developerConnection&gt;scm:svn:https://127.0.0.1/dummy&lt;/developerConnection&gt;
          &lt;tag&gt;HEAD&lt;/tag&gt;
      &lt;/scm&gt;
  
      &lt;build&gt;
          &lt;finalName&gt;jenkins_build_deploy&lt;/finalName&gt;
  
          &lt;resources&gt;
              &lt;resource&gt;
                  &lt;directory&gt;${basedir}/src/main/resources&lt;/directory&gt;
                  &lt;filtering&gt;true&lt;/filtering&gt;
                  &lt;includes&gt;
                      &lt;include&gt;**/*.properties&lt;/include&gt;
                  &lt;/includes&gt;
              &lt;/resource&gt;
              &lt;resource&gt;
                  &lt;directory&gt;${basedir}/src/main/resources&lt;/directory&gt;
                  &lt;filtering&gt;false&lt;/filtering&gt;
                  &lt;excludes&gt;
                      &lt;exclude&gt;**/*.properties&lt;/exclude&gt;
                  &lt;/excludes&gt;
              &lt;/resource&gt;
          &lt;/resources&gt;
  
  
  
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.5.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                      &lt;encoding&gt;UTF-8&lt;/encoding&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.1-alpha-2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;webappDirectory&gt;${project.build.directory}/${project.artifactId}&lt;/webappDirectory&gt;
                      &lt;warName&gt;${project.artifactId}&lt;/warName&gt;
                      &lt;webResources&gt;
                          &lt;resource&gt;
                              &lt;filtering&gt;true&lt;/filtering&gt;
                              &lt;directory&gt;${basedir}/src/main/resources&lt;/directory&gt;
  
                              &lt;directory&gt;${project.build.directory}&lt;/directory&gt;
                              &lt;directory&gt;${project.build.sourceDirectory}&lt;/directory&gt;
                              &lt;targetPath&gt;WEB-INF/classes&lt;/targetPath&gt;
                          &lt;/resource&gt;
                      &lt;/webResources&gt;
                      &lt;nonFilteredFileExtensions&gt;
                          &lt;nonFilteredFileExtension&gt;gif&lt;/nonFilteredFileExtension&gt;
                          &lt;nonFilteredFileExtension&gt;ico&lt;/nonFilteredFileExtension&gt;
                          &lt;nonFilteredFileExtension&gt;jpg&lt;/nonFilteredFileExtension&gt;
                          &lt;nonFilteredFileExtension&gt;png&lt;/nonFilteredFileExtension&gt;
                          &lt;nonFilteredFileExtension&gt;pdf&lt;/nonFilteredFileExtension&gt;
                          &lt;nonFilteredFileExtension&gt;jasper&lt;/nonFilteredFileExtension&gt;
                      &lt;/nonFilteredFileExtensions&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.6&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;copy-resources&lt;/id&gt;
                          &lt;!-- here the phase you need --&gt;
                          &lt;phase&gt;validate&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;copy-resources&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;outputDirectory&gt;${basedir}/target/WEB-INF/classes&lt;/outputDirectory&gt;
                              &lt;resources&gt;
                                  &lt;resource&gt;
                                      &lt;filtering&gt;true&lt;/filtering&gt;
  
                                      &lt;directory&gt;${basedir}/src/main/resources&lt;/directory&gt;
  
                                      &lt;directory&gt;${project.build.directory}&lt;/directory&gt;
                                      &lt;directory&gt;${project.build.sourceDirectory}&lt;/directory&gt;
                                  &lt;/resource&gt;
                              &lt;/resources&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.glassfish.maven.plugin&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-glassfish-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;debug&gt;true&lt;/debug&gt;
                      &lt;echo&gt;true&lt;/echo&gt;
                      &lt;terse&gt;true&lt;/terse&gt;
                      &lt;force&gt;true&lt;/force&gt;
                      &lt;!-- &lt;autoCreate&gt;true&lt;/autoCreate&gt; --&gt;
                      &lt;!-- &lt;skip&gt;${test.int.skip}&lt;/skip&gt; --&gt;
                      &lt;glassfishDirectory&gt;${glassfish.glassfishDirectory}&lt;/glassfishDirectory&gt;
                      &lt;user&gt;${glassfish.user}&lt;/user&gt;
                      &lt;adminPassword&gt;${glassfish.adminPassword}&lt;/adminPassword&gt;
                      &lt;!-- &lt;passwordFile&gt;${glassfish.home}/domains/${project.artifactId}/master-password&lt;/passwordFile&gt; --&gt;
                      &lt;domain&gt;
                          &lt;name&gt;${glassfish.domain.name}&lt;/name&gt;
                          &lt;host&gt;${glassfish.domain.host}&lt;/host&gt;
                          &lt;adminPort&gt;${glassfish.domain.adminPort}&lt;/adminPort&gt;
                      &lt;/domain&gt;
                      &lt;components&gt;
                          &lt;component&gt;
                              &lt;name&gt;${project.artifactId}&lt;/name&gt;
                              &lt;artifact&gt;${project.build.directory}/${project.artifactId}.war&lt;/artifact&gt;
                          &lt;/component&gt;
                      &lt;/components&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;redeploy&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
  
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.12.4&lt;/version&gt;
                  &lt;dependencies&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;org.apache.maven.surefire&lt;/groupId&gt;
                          &lt;artifactId&gt;surefire-junit47&lt;/artifactId&gt;
                          &lt;version&gt;2.12.4&lt;/version&gt;
                      &lt;/dependency&gt;
                  &lt;/dependencies&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;buildnumber-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;buildnumber&lt;/id&gt;
                          &lt;phase&gt;validate&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;create&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;doCheck&gt;false&lt;/doCheck&gt;
                      &lt;doUpdate&gt;false&lt;/doUpdate&gt;
                      &lt;revisionOnScmFailure&gt;unknownbuild&lt;/revisionOnScmFailure&gt;
                      &lt;format&gt;{0,number}&lt;/format&gt;
                      &lt;items&gt;
                          &lt;item&gt;buildNumber&lt;/item&gt;
                      &lt;/items&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              ****
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>jenkins/config.xml</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;maven2-moduleset plugin="maven-plugin@1.501"&gt;
      &lt;actions/&gt;
      &lt;description&gt;jenkins_build_deploy&lt;/description&gt;
      &lt;keepDependencies&gt;false&lt;/keepDependencies&gt;
      &lt;properties&gt;
          &lt;hudson.model.ParametersDefinitionProperty&gt;
              &lt;parameterDefinitions&gt;
                  &lt;hudson.model.StringParameterDefinition&gt;
                      &lt;name&gt;CUSTOM_VERSION&lt;/name&gt;
                      &lt;description&gt;custom_version  = Test 1.0 ${env.CUSTOM_VERSION}&lt;/description&gt;
                      &lt;defaultValue&gt;1.0.1&lt;/defaultValue&gt;
                  &lt;/hudson.model.StringParameterDefinition&gt;
                  &lt;hudson.model.StringParameterDefinition&gt;
                      &lt;name&gt;CUSTOM_MESSAGE&lt;/name&gt;
                      &lt;description&gt;Test Env.&lt;/description&gt;
                      &lt;defaultValue&gt;Test Env.&lt;/defaultValue&gt;
                  &lt;/hudson.model.StringParameterDefinition&gt;
              &lt;/parameterDefinitions&gt;
          &lt;/hudson.model.ParametersDefinitionProperty&gt;
      &lt;/properties&gt;
      &lt;scm class="hudson.scm.SubversionSCM" plugin="subversion@1.45"&gt;
          &lt;locations&gt;
              &lt;hudson.scm.SubversionSCM_-ModuleLocation&gt;
                  &lt;remote&gt;http://example.com/svn/jenkins_build_deploy/trunk&lt;/remote&gt;
                  &lt;local&gt;.&lt;/local&gt;
                  &lt;depthOption&gt;infinity&lt;/depthOption&gt;
                  &lt;ignoreExternalsOption&gt;false&lt;/ignoreExternalsOption&gt;
              &lt;/hudson.scm.SubversionSCM_-ModuleLocation&gt;
          &lt;/locations&gt;
          &lt;excludedRegions/&gt;
          &lt;includedRegions/&gt;
          &lt;excludedUsers/&gt;
          &lt;excludedRevprop/&gt;
          &lt;excludedCommitMessages/&gt;
          &lt;workspaceUpdater class="hudson.scm.subversion.UpdateUpdater"/&gt;
          &lt;ignoreDirPropChanges&gt;false&lt;/ignoreDirPropChanges&gt;
          &lt;filterChangelog&gt;false&lt;/filterChangelog&gt;
      &lt;/scm&gt;
      &lt;canRoam&gt;true&lt;/canRoam&gt;
      &lt;disabled&gt;false&lt;/disabled&gt;
      &lt;blockBuildWhenDownstreamBuilding&gt;false&lt;/blockBuildWhenDownstreamBuilding&gt;
      &lt;blockBuildWhenUpstreamBuilding&gt;false&lt;/blockBuildWhenUpstreamBuilding&gt;
      &lt;triggers class="vector"/&gt;
      &lt;concurrentBuild&gt;false&lt;/concurrentBuild&gt;
      &lt;rootModule&gt;
          &lt;groupId&gt;com.example&lt;/groupId&gt;
          &lt;artifactId&gt;jenkins_build_deploy&lt;/artifactId&gt;
      &lt;/rootModule&gt;
      &lt;goals&gt;clean install -Dmaven.test.skip=true glassfish:deploy&lt;/goals&gt;
      &lt;aggregatorStyleBuild&gt;true&lt;/aggregatorStyleBuild&gt;
      &lt;incrementalBuild&gt;false&lt;/incrementalBuild&gt;
      &lt;perModuleEmail&gt;true&lt;/perModuleEmail&gt;
      &lt;ignoreUpstremChanges&gt;false&lt;/ignoreUpstremChanges&gt;
      &lt;archivingDisabled&gt;false&lt;/archivingDisabled&gt;
      &lt;resolveDependencies&gt;false&lt;/resolveDependencies&gt;
      &lt;processPlugins&gt;false&lt;/processPlugins&gt;
      &lt;mavenValidationLevel&gt;-1&lt;/mavenValidationLevel&gt;
      &lt;runHeadless&gt;false&lt;/runHeadless&gt;
      &lt;disableTriggerDownstreamProjects&gt;false&lt;/disableTriggerDownstreamProjects&gt;
      &lt;settings class="jenkins.mvn.DefaultSettingsProvider"/&gt;
      &lt;globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/&gt;
      &lt;reporters/&gt;
      &lt;publishers/&gt;
      &lt;buildWrappers/&gt;
      &lt;prebuilders&gt;
          &lt;hudson.tasks.Shell&gt;
              &lt;command&gt;echo CUSTOM_VERSION: $CUSTOM_VERSION
  echo CUSTOM_MESSAGE: $CUSTOM_MESSAGE&lt;/command&gt;
          &lt;/hudson.tasks.Shell&gt;
      &lt;/prebuilders&gt;
      &lt;postbuilders/&gt;
      &lt;runPostStepsIfResult&gt;
          &lt;name&gt;FAILURE&lt;/name&gt;
          &lt;ordinal&gt;2&lt;/ordinal&gt;
          &lt;color&gt;RED&lt;/color&gt;
      &lt;/runPostStepsIfResult&gt;
  &lt;/maven2-moduleset&gt;
  </code></pre>