1

I have a scala project and it is under a Jenkins build setup and at last it will be run under a docker container.

Sometimes I doubt the process of build and I don't sure if the compiled jar file the latest version or the build process was broken and the resulting container still runs with the older version of the jar.

Is there any common way to relate the jar file to the commit (For example commit the latest commit id into the sources ... )?

Is there any tooling for this job?

torek
  • 448,244
  • 59
  • 642
  • 775

1 Answers1

1

Possible duplicate of Add git commit id in fat jar manifest using sbt


One other way can be to use sbt-buildinfo plugin.

With following setup in the build.sbt (for instance):

.settings(
  ...,
  BuildInfoKey.action("gitHeadRev") {
    scala.sys.process.Process("git rev-parse HEAD").!!.trim
  }
)

Then you can use the info (commit hash) in your code how you want. For instance expose it somehow (endpoint, a file..).

Gaël J
  • 11,274
  • 4
  • 17
  • 32