# Support incrementing existing versionCode using step

**URL:** <https://discuss.bitrise.io/t/support-incrementing-existing-versioncode-using-step/16935>\
**Category:** Steps\
**Tags:** step, android\
**Created:** [May 22, 2021, 12:24pm UTC](https://discuss.bitrise.io/t/support-incrementing-existing-versioncode-using-step/16935 "2021-05-22T12:24:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anthonymonori](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anthonymonori](https://discuss.bitrise.io/u/anthonymonori)\
**Post date:** [May 22, 2021, 12:24pm UTC](https://discuss.bitrise.io/t/support-incrementing-existing-versioncode-using-step/16935/1 "2021-05-22T12:24:20Z")

</div>

## Description of the feature request

Reading through the [documentation](https://devcenter.bitrise.io/builds/build-numbering-and-app-versioning/#setting-the-versioncode-and-the-versionname-of-an-android-app) and the [code](https://github.com/bitrise-steplib/steps-change-android-versioncode-and-versionname/blob/master/main.go#L98-L112) for the **steps-change-android-versioncode-and-versionname** step, for setting up versionCode (I’m disregarding any logic for versionName in this request) you have to define a predefined value (or env variable) as a new value, or default to `$BITRISE_BUILD_NUMBER`. Even when used in conjunction with the `version_code_offset` property, it assumes that a valid `new_version_code` is set.

## Use case / for what or how I would use it

My use case is that I would like the step to help me just increment the **existing `versionCode`** by the `version_code_offset` value. The step already parses the existing `versionCode` in the [code](https://github.com/bitrise-steplib/steps-change-android-versioncode-and-versionname/blob/master/main.go#L100), so it would be great to make `new_version_code` optional or to not break current default behavior, just accept `''` (empty string) as input (so it doesn’t default to `$BITRISE_BUILD_NUMBER` when it’s undeclared) and just simply increase the current `versionCode` by the value set in `new_version_code` (if set, otherwise skip)

It is possible to do this today in two steps:

```
  - script@1:
      inputs:
        - content: >-
            envman add --key CURRENT_VERSION_CODE --value "$(grep -P
            'versionCode(?:\s|=)+(.*?)(?:\s|\/\/|$)' $PROJECT_LOCATION/$MODULE//build.gradle |
            awk '{ print $2}')"
      title: Temporary solution to get current versionCode
  - change-android-versioncode-and-versionname@1:
      inputs:
        - new_version_code: $CURRENT_VERSION_CODE
        - version_code_offset: 1
        - build_gradle_path: $BITRISE_SOURCE_DIR/$MODULE/build.gradle
      title: Update versionCode and versionName

```

But you get the idea – this is not ideal since we both parse the same regexp in two places instead of just doing it in one

---

<div class="post-metadata">

**Author:** ![allenenorton](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/allenenorton/32/3520_2.png) [@allenenorton](https://discuss.bitrise.io/u/allenenorton)\
**Post date:** [June 7, 2021, 2:58pm UTC](https://discuss.bitrise.io/t/support-incrementing-existing-versioncode-using-step/16935/2 "2021-06-07T14:58:14Z")

</div>

Thanks for the #feature-request! We’ll keep an eye on the votes 😉
