2

This question is somehow related to Using Jenkins BUILD NUMBER in RPM spec file.

You can access the build number in a Jenkins process using the environment variable ${BUILD_NUMBER}. But how can I use this environment variable within my Play! build.sbt file to set rpmRelease := "..." to the actual build number?

The RPM is built within Jenkins using the simple Shell command activator rpm:packageBin.

Community
  • 1
  • 1
dnl
  • 365
  • 1
  • 4
  • 14
  • I'm answering as a comment b/c I'm not sure, but one thing to try is passing arbitrary values to your application.conf. See the very bottom of https://playframework.com/documentation/2.3.x/Configuration. So, in Jenkins, you could run a terminal command like `activator -DrpmRelease=${BUILD_NUMBER} dist`. – Josh Padnick Sep 18 '14 at 17:24

1 Answers1

4

You can place scala code in your build.sbt file, so something like this should work:

rpmRelease := sys.env("BUILD_NUMBER")

or if you need to provide a default value:

rpmRelease := sys.env.get("BUILD_NUMBER").getOrElse("SOME DEFAULT VALUE")
Salem
  • 12,808
  • 4
  • 34
  • 54