getsentry/sentry-dart-plugin

`SENTRY_DIST` env. variable doesn't work

feinstein opened this issue · 10 comments

Environment

1.7.1

Steps to Reproduce

I have the following script:

SENTRY_DIST=$BUILD_NUMBER
echo "Sentry distribution number: $SENTRY_DIST"
dart run sentry_dart_plugin

this prints:

Sentry distribution number: 14

But after the sentry_dart_plugin runs I see this:

Created release my_app@0.0.1+1

So it doesn't seem to me that SENTRY_DIST is being used by the CLI, as I am expecting to see my_app@0.0.1+14.

Hi!

just a sanity check, you didn't set up dist in pubspec or sentry.properties?

They way it works is that it checks the configuration files first and if it can't find it it will choose the env var

I didn't, but I have the version set-up in pubspec.yaml, but I override the build number in my CICD script, as a flag for the Flutter build tool

Just checked AFAIK we explicitly added a test that the build number from release/version is used as dist:

test('custom release with a dist in it', () async {

So this seems to be expected behaviour, but I can't tell what the reasoning behind this was.

It seems either release or versions build number has precedence over any provided dist.

String get _release {
  var release = '';

  if (_configuration.release?.isNotEmpty ?? false) {
    release = _configuration.release!;
  } else {
    release = _configuration.name;
  }

  if (!release.contains('@')) {
    release += '@${_configuration.version}';
  }

  final dist = _dist;
  if (!release.contains('+') && (dist?.isNotEmpty ?? false)) {
    release += '+${dist!}';
  }
  return release;
}

This doesn't make sense to me, pubspec.yaml versions are the expected way to define versions, so all other methods are used to override that one.

The Flutter tool has flags to override pubspec.yaml, and so should your environment variable do.

It's common for CICDs to automatically generate a build number and no one wants to change the pubspec.yaml from a CICD bash script to inject the distribution number.

I think this issue still persists. I am using version 2.1.0 and I got this output:

☑ uploading debug symbols

Created release my_app@0.0.1+1

But my command was

SENTRY_DIST=$APP_BUILD_NUMBER
echo "Sentry distribution number: $SENTRY_DIST"
dart run sentry_dart_plugin

Where APP_BUILD_NUMBER was 4, which was confirmed by the echo as:

Sentry distribution number: 4

hm I could not reproduce this, it works on my local build

# in my pubspec.yaml
version: 1.0.0+1
export SENTRY_DIST=4

running the dart plugin leads to Created release flutter_sentry_test@1.0.0+4

can you share your full plugin configuration?

Can you try with a Squash commit where the plugin doesn't find the previous commit?

not sure how the commits are linked to dist not being set correctly, afaik the commits are only used to associate to the release

can you share your full plugin configuration?

Is this what you are asking for?

sentry_dart_plugin: ^2.1.0

sentry:
  project: my_project
  org: my_org

My CICD runs this: dart run sentry_dart_plugin

@buenaflor it was my mistake sorry, I forgot to use export to make the env variable available to the child process