ajoberstar / reckon

Infer a project's version from your Git repository.
Apache License 2.0
187 stars 28 forks source link

Feature request: write the reckoned version to a buildDir file #165

Closed djechelon closed 9 months ago

djechelon commented 2 years ago

Why?

I am using Azure DevOps Pipelines, and one of my dirty tasks is to identify the artifact version to be used in the next stages, especially when the artifact is a Docker artifact

Currently, Jib writes the Docker Image ID to $buildDir/jib-image.id, which is damn cool.

What if reckon writes a similar file? I could catch up in a subsequent step, using vso.setVariable consuming the contents of the file. This way, the assigned artifact version will be available to subsequent DevOps stages and steps

ajoberstar commented 2 years ago

I'm on the fence about whether this should be part of the plugin. But in the meantime, this is pretty easy to just add to your build.gradle.

tasks.register('versionFile') {
  doLast {
    file("${buildDir}/version.txt").text = version.toString()
  }
}

You could do more to add inputs that avoid re-writing it, but it depends on the use case. If you only run it when publishing (or in a clean repo state in CI) you can keep it simple.

ajoberstar commented 9 months ago

No plan to provide this in the plugin, the workaround posted earlier should meet the need though.