Esempio n. 1
0
        private int GetBuildNumber(PerforceSettings settings)
        {
            if (Platform.IsUnityCloudBuild == false)
            {
                // NOTE [bgish]: Gradle Build will fail if build number is 0, so returning 1
                // android.defaultConfig.versionCode is set to 0, but it should be a positive integer.
                return(1);
            }

            var cloudBuildManifest = CloudBuildManifest.Find();

            if (cloudBuildManifest == null)
            {
                Debug.LogError("PerforceSettings couldn't find CloudBuildManifest!");
            }
            else if (settings.buildNumberType == BuildNumberType.None)
            {
                Debug.Log("PerforceSettings skipping setting application build number");
            }
            else if (settings.buildNumberType == BuildNumberType.BuildNumber)
            {
                Debug.LogFormat("PerforceSettings setting application build number to unity cloud BuildNumber {0}!", cloudBuildManifest.BuildNumber);
                return(cloudBuildManifest.BuildNumber);
            }
            else if (settings.buildNumberType == BuildNumberType.CommitNumber)
            {
                string commitId = cloudBuildManifest.ScmCommitId;

                if (int.TryParse(commitId, out int commitNumber))
                {
                    Debug.LogFormat("PerforceSettings setting application build number to ScmCommitId {0}!", commitId);
                    return(commitNumber);
                }
                else
                {
                    Debug.LogErrorFormat("PerforceSettings couldn't parse ScmCommitId {0}.  It is not a valid integer!", commitId);
                }
            }
            else
            {
                Debug.LogErrorFormat("Found unknown BuildNumberType {0}", settings.buildNumberType);
            }

            return(-1);
        }
Esempio n. 2
0
        private void SendCloudBuildEvent()
        {
            var manifest = CloudBuildManifest.Find();

            if (manifest == null)
            {
                return;
            }

            Analytics.AnalyticsEvent.Custom("unity_cloud_build", new Dictionary <string, object>
            {
                { "branch", manifest.ScmBranch },
                { "commit_id", manifest.ScmCommitId },
                { "build_number", manifest.BuildNumber },
                { "target_name", manifest.CloudBuildTargetName },
                { "unity_version", manifest.UnityVersion },
                { "bundle_id", manifest.BundleId },
                { "project_id", manifest.ProjectId },
            });
        }