Skip to content

Commit e730f75

Browse files
committed
Fix BUILDKITE_PULL_REQUEST being false not nil
1 parent fbd47bf commit e730f75

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

fastlane/Fastfile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ platform :ios do
744744
build_for_prototype_build
745745

746746
release_notes = <<~NOTES
747-
Pull Request: ##{ENV.fetch('BUILDKITE_PULL_REQUEST', 'N/A')}
747+
Pull Request: ##{pull_request_number || 'N/A'}
748748
Branch: `#{ENV.fetch('BUILDKITE_BRANCH', 'N/A')}`
749749
Commit: #{ENV.fetch('BUILDKITE_COMMIT', 'N/A')[0...7]}
750750
NOTES
@@ -763,13 +763,13 @@ platform :ios do
763763
dsym_path: './build/WooCommerce.app.dSYM.zip'
764764
)
765765

766-
next if ENV.fetch('BUILDKITE_PULL_REQUEST', 'false') == 'false'
766+
next if pull_request_number.nil?
767767

768768
# PR Comment
769769
comment_body = prototype_build_details_comment(app_display_name: 'WooCommerce iOS Prototype')
770770
comment_on_pr(
771771
project: GITHUB_REPO,
772-
pr_number: Integer(ENV.fetch('BUILDKITE_PULL_REQUEST')),
772+
pr_number: pull_request_number,
773773
reuse_identifier: 'prototype-build-link',
774774
body: comment_body
775775
)
@@ -780,7 +780,7 @@ platform :ios do
780780
update_certs_and_profiles_enterprise if fetch_code_signing
781781

782782
build_number = ENV.fetch('BUILDKITE_BUILD_NUMBER', '0')
783-
pr_or_branch = ENV.fetch('BUILDKITE_PULL_REQUEST', nil)&.then { |num| "PR ##{num}" } || ENV.fetch('BUILDKITE_BRANCH', nil)
783+
pr_or_branch = pull_request_number&.then { |num| "PR ##{num}" } || ENV.fetch('BUILDKITE_BRANCH', nil)
784784

785785
gym(
786786
scheme: 'WooCommerce Alpha',
@@ -1473,13 +1473,6 @@ def prompt_user_for_app_store_connect_credentials
14731473
ENV['FASTLANE_USER'] = CredentialsManager::AccountManager.new.user
14741474
end
14751475

1476-
def override_default_release_branch(version)
1477-
success = Fastlane::Helper::GitHelper.checkout_and_pull(release: version)
1478-
UI.user_error!("Release branch for version #{version} doesn't exist. Abort.") unless success
1479-
1480-
UI.message("Checked out branch `#{git_branch}` as requested by user.\n")
1481-
end
1482-
14831476
# https://buildkite.com/docs/test-analytics/ci-environments
14841477
TEST_ANALYTICS_ENVIRONMENT = %w[
14851478
BUILDKITE_ANALYTICS_TOKEN
@@ -1495,6 +1488,13 @@ TEST_ANALYTICS_ENVIRONMENT = %w[
14951488
# -----------------------------------------------------------------------------------
14961489
# Release Management Utils
14971490
# -----------------------------------------------------------------------------------
1491+
1492+
def pull_request_number
1493+
# Buildkite sets this env var to the PR number if on a PR, but to 'false' (and not nil) if not on a PR
1494+
pr_num = ENV.fetch('BUILDKITE_PULL_REQUEST', 'false')
1495+
pr_num == 'false' ? nil : Integer(pr_num)
1496+
end
1497+
14981498
def create_backmerge_pr
14991499
version = release_version_current
15001500

0 commit comments

Comments
 (0)