• Motivation:  in continues deployment there is some sense indicating build number in the app version. not just GIT hash (nobody knows the meaning of …)
    • In this example: we will use sbt + docker plugin. after understanding the idea you can achieve this in many different methods.
    • Basically we need to pass build# into our app, the build# is provided by the build system, Jenkins sets a ENV variable named $BUILD_NUMBER in the scope of the running build. we will use it and pass to a docker container. later when needed (from some api call) we will fetch the ENV var that was passed to the container by sbt from the Jenkins machine.
    • Add sbt docker plugin 

    • Build objects common version handling looks similar to  :

    • Using sbt docker plugin we can pass ENV variables from the build machine to the docker

    • Finished ! only thing left is to call the ENV variable when needed, for example in a controller for an api call :

    • Bonus ! in the UI you can add a direct link from the App version to Jenkins simply by checking on the URL structure on your build and add the build number in it! this way is some 1 want to check if his changes are already committed to this build he can click on the product version in the UI and view the change list on Jenkins! 
      link to jenkins build

Share Button