ajoberstar / reckon

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

Reckon cannot determine correct action when infering version in bitbucket pipeline #187

Closed NeelVanhecke closed 6 months ago

NeelVanhecke commented 1 year ago

We have been using Reckon as our automated versioning system for a while without issues. We use Reckon in our bitbucket pipeline to create tags based on the branch that has been pushed to the remote. See following snippet from our bitbucket-pipelines.yml:

pipelines:
  branches:
    develop:
      - step:
          name: Unit tests
          caches:
            - gradle
          script:
            - java --version
            - ./gradlew test
          artifacts:
            - build/reports/jacoco/test/html/**
      - step:
          name: push reckonTag
          script:
            - ./gradlew reckonTagPush -Preckon.scope=minor -Preckon.stage=dev -Dorg.ajoberstar.grgit.auth.username=$BITBUCKET_USERNAME -Dorg.ajoberstar.grgit.auth.password=$BITBUCKET_APP_PASSWORD
            - ./gradlew build -x test
          artifacts:
            - build/libs/*.jar

and the use of reckon in our build.gradle file:

reckon {
    stages('dev', 'rc', 'final')

    // how do you calculate the scope/stage
    scopeCalc = calcScopeFromProp().or(calcScopeFromCommitMessages())
    // fall back to commit message (see below) if no explicit prop set
    stageCalc = calcStageFromProp()

    defaultInferredScope = 'patch'
}

However, since 13/09/2022, our pipeline has been failing with the following error during the Unit tests step:

  • What went wrong: Could not determine the dependencies of task ':test'. Could not resolve all dependencies for configuration ':jacocoAgent'. Failed to calculate the value of extension 'reckon' property 'version'. Scope between bases 0.0.0 and 0.3.0-dev.46 must be same or 1 MAJOR/MINOR/PATCH increment apart and are not. Cannot determine correct action.

I believe this is due to another gradle plugin trying to access the reckon.version() property before it is configured properly but I also already tried to only run the reckonTagCreate task via our pipeline which fails with this warning:

  • What went wrong: Execution failed for task ':reckonTagCreate'. Failed to calculate the value of task ':reckonTagCreate' property 'tagMessage'. Failed to query the value of extension 'reckon' property 'tagMessage'. Failed to calculate the value of extension 'reckon' property 'version'. Scope between bases 0.0.0 and 0.3.0-dev.46 must be same or 1 MAJOR/MINOR/PATCH increment apart and are not. Cannot determine correct action.

I am using Gradle 7.4, together with Reckon version 0.16.0. I have tried the solution from Reckon 0.17.0-beta.2 with defining the plugin from settings.gradle instead of build.gradle but to no avail. Locally, everything runs fine, the problem only arises when pushing to our remote.

Note that git tag --list ran in the bitbucket pipeline returns the list with tags as expected:

  • git tag --list 0.3.0-dev.26 0.3.0-dev.27 0.3.0-dev.28 0.3.0-dev.29 0.3.0-dev.30 0.3.0-dev.31 0.3.0-dev.32 0.3.0-dev.33 0.3.0-dev.34 0.3.0-dev.35 0.3.0-dev.36 0.3.0-dev.37 0.3.0-dev.38 0.3.0-dev.39 0.3.0-dev.40 0.3.0-dev.41 0.3.0-dev.42 0.3.0-dev.43 0.3.0-dev.44 0.3.0-dev.45 0.3.0-dev.46

And that git describe --tags --abbrev=0 correctly returns

0.3.0-dev.46

ajoberstar commented 6 months ago

I think it's tripped up by there being only 0.3.0-dev.* version tags and no prior final version tagged. If you tag 0.2.0 I think it would resolve this.