0

I am using https://github.com/sbt/sbt-native-packager and https://github.com/sbt/sbt-git plugins.

When I run the following command:

    # docker image
    sbt docker:publishLocal

I would like to carry out this task:

    git.useGitDescribe := true
    git.formattedShaVersion := git.gitHeadCommit.value map { _ =>
      git.gitCurrentTags.value.head
    }

    Docker / dockerAlias := DockerAlias(None, Some("zerocoder"), (packageName in Docker).value, git.gitDescribedVersion.value)

The task above should be only executed by docker:publishLocal command. How to archive it?

softshipper
  • 32,463
  • 51
  • 192
  • 400

1 Answers1

1

Since state needs to be modified before executing a task, try defining a custom command like so:

commands += Command.command("publishLocalWithGit") { state =>
  """set git.useGitDescribe := true""" ::
  """set git.formattedShaVersion := git.gitHeadCommit.value map { _ => git.gitCurrentTags.value.head }""" ::
  """set Docker / dockerAlias := DockerAlias(None, Some("zerocoder"), (packageName in Docker).value, git.gitDescribedVersion.value)""" ::
  """docker:publishLocal""" ::  state
}

Execute the command with sbt publishLocalWithGit.

Mario Galic
  • 47,285
  • 6
  • 56
  • 98