static Startup() { Triggers <BuildChannel> .Inserted += entry => { BuildAssetRegistryContext context = entry.Context as BuildAssetRegistryContext; ILogger <Startup> logger = context.GetService <ILogger <Startup> >(); BuildChannel entity = entry.Entity; Build build = context.Builds .Include(b => b.Assets) .ThenInclude(a => a.Locations) .FirstOrDefault(b => b.Id == entity.BuildId); if (build == null) { logger.LogError($"Could not find build with id {entity.BuildId} in BAR. Skipping dependency update."); } else { bool hasAssetsWithPublishedLocations = build.Assets .Any(a => a.Locations.Any(al => al.Type != LocationType.None && !al.Location.EndsWith("/artifacts"))); if (hasAssetsWithPublishedLocations || ReposWithoutAssetLocationAllowList.Contains(build.GitHubRepository)) { var queue = context.GetService <IBackgroundQueue>(); queue.Post <StartDependencyUpdate>(StartDependencyUpdate.CreateArgs(entity)); } else { logger.LogInformation($"Skipping Dependency update for Build {entity.BuildId} because it contains no assets in valid locations"); } } }; }
static Startup() { Triggers <BuildChannel> .Inserting += entry => { BuildAssetRegistryContext context = entry.Context as BuildAssetRegistryContext; BuildChannel entity = entry.Entity; Build build = context.Builds.Find(entity.BuildId); if (build == null) { ILogger <Startup> logger = context.GetService <ILogger <Startup> >(); logger.LogError($"Could not find build with id {entity.BuildId} in BAR. Skipping pipeline triggering."); } else { if (build.PublishUsingPipelines && ChannelHasAssociatedReleasePipeline(entity.ChannelId, context)) { entry.Cancel = true; var queue = context.GetService <BackgroundQueue>(); var releasePipelineRunner = context.GetService <IReleasePipelineRunner>(); queue.Post(() => releasePipelineRunner.StartAssociatedReleasePipelinesAsync(entity.BuildId, entity.ChannelId)); } } }; Triggers <BuildChannel> .Inserted += entry => { DbContext context = entry.Context; BuildChannel entity = entry.Entity; var queue = context.GetService <BackgroundQueue>(); var dependencyUpdater = context.GetService <IDependencyUpdater>(); queue.Post(() => dependencyUpdater.StartUpdateDependenciesAsync(entity.BuildId, entity.ChannelId)); }; }
public async Task <IActionResult> AddBuildToChannel(int channelId, int buildId) { Data.Models.Channel channel = await _context.Channels.FindAsync(channelId); if (channel == null) { return(NotFound(new ApiError($"The channel with id '{channelId}' was not found."))); } Build build = await _context.Builds.FindAsync(buildId); if (build == null) { return(NotFound(new ApiError($"The build with id '{buildId}' was not found."))); } // If build is already in channel, nothing to do if (build.BuildChannels != null && build.BuildChannels.Any(existingBuildChannels => existingBuildChannels.ChannelId == channelId)) { return(StatusCode((int)HttpStatusCode.Created)); } var buildChannel = new BuildChannel { Channel = channel, Build = build }; await _context.BuildChannels.AddAsync(buildChannel); await _context.SaveChangesAsync(); return(StatusCode((int)HttpStatusCode.Created)); }
static Startup() { Triggers <BuildChannel> .Inserting += entry => { BuildAssetRegistryContext context = entry.Context as BuildAssetRegistryContext; BuildChannel entity = entry.Entity; Build build = context.Builds.Find(entity.BuildId); if (build == null) { ILogger <Startup> logger = context.GetService <ILogger <Startup> >(); logger.LogError($"Could not find build with id {entity.BuildId} in BAR. Skipping pipeline triggering."); } else { if (build.PublishUsingPipelines && ChannelHasAssociatedReleasePipeline(entity.ChannelId, context)) { entry.Cancel = true; var queue = context.GetService <BackgroundQueue>(); var releasePipelineRunner = context.GetService <IReleasePipelineRunner>(); queue.Post(() => releasePipelineRunner.StartAssociatedReleasePipelinesAsync(entity.BuildId, entity.ChannelId)); } } }; Triggers <BuildChannel> .Inserted += entry => { BuildAssetRegistryContext context = entry.Context as BuildAssetRegistryContext; ILogger <Startup> logger = context.GetService <ILogger <Startup> >(); BuildChannel entity = entry.Entity; Build build = context.Builds .Include(b => b.Assets) .ThenInclude(a => a.Locations) .FirstOrDefault(b => b.Id == entity.BuildId); if (build == null) { logger.LogError($"Could not find build with id {entity.BuildId} in BAR. Skipping dependency update."); } else { bool hasAssetsWithPublishedLocations = build.Assets .Any(a => a.Locations.Any(al => al.Type != LocationType.None && !al.Location.EndsWith("/artifacts"))); if (hasAssetsWithPublishedLocations) { var queue = context.GetService <BackgroundQueue>(); var dependencyUpdater = context.GetService <IDependencyUpdater>(); queue.Post(() => dependencyUpdater.StartUpdateDependenciesAsync(entity.BuildId, entity.ChannelId)); } else { logger.LogInformation($"Skipping Dependency update for Build {entity.BuildId} because it contains no assets in valid locations"); } } }; }
private void OnEnable() { _buildOutputPath = $"{Application.dataPath}/../BuildResult"; _buildChannel = BuildChannel.Oppo; _buildVersionCode = 1; _isCompleteBuild = true; _isBuildAssetBundle = true; _isRelease = false; }
static Startup() { Triggers <BuildChannel> .Inserted += entry => { BuildChannel entity = entry.Entity; DbContext context = entry.Context; var queue = context.GetService <BackgroundQueue>(); var dependencyUpdater = context.GetService <IDependencyUpdater>(); queue.Post(() => dependencyUpdater.StartUpdateDependenciesAsync(entity.BuildId, entity.ChannelId)); }; }
public virtual async Task <IActionResult> RemoveBuildFromChannel(int channelId, int buildId) { BuildChannel buildChannel = await _context.BuildChannels .Where(bc => bc.BuildId == buildId && bc.ChannelId == channelId) .FirstOrDefaultAsync(); if (buildChannel == null) { return(StatusCode((int)HttpStatusCode.NotModified)); } _context.BuildChannels.Remove(buildChannel); await _context.SaveChangesAsync(); return(StatusCode((int)HttpStatusCode.OK)); }
public async Task UpToDateSubscription() { var channel = new Channel { Name = "channel", Classification = "class" }; var build = new Build { Branch = "source.branch", Repository = "source.repo", BuildNumber = "build.number", Commit = "sha", DateProduced = DateTimeOffset.UtcNow }; var buildChannel = new BuildChannel { Build = build, Channel = channel }; var subscription = new Subscription { Channel = channel, SourceRepository = "source.repo", TargetRepository = "target.repo", TargetBranch = "target.branch", PolicyObject = new SubscriptionPolicy { MergePolicies = null, UpdateFrequency = UpdateFrequency.EveryDay }, LastAppliedBuild = build }; await Context.Subscriptions.AddAsync(subscription); await Context.BuildChannels.AddAsync(buildChannel); await Context.SaveChangesAsync(); var updater = ActivatorUtilities.CreateInstance <DependencyUpdater>(Scope.ServiceProvider); await updater.CheckSubscriptionsAsync(CancellationToken.None); }
public override async Task <IActionResult> AddBuildToChannel(int channelId, int buildId) { Data.Models.Channel channel = await _context.Channels.FindAsync(channelId); if (channel == null) { return(NotFound(new ApiError($"The channel with id '{channelId}' was not found."))); } Build build = await _context.Builds .Where(b => b.Id == buildId) .Include(b => b.BuildChannels) .FirstOrDefaultAsync(); if (build == null) { return(NotFound(new ApiError($"The build with id '{buildId}' was not found."))); } // If build is already in channel, nothing to do if (build.BuildChannels.Any(existingBuildChannels => existingBuildChannels.ChannelId == channelId)) { return(StatusCode((int)HttpStatusCode.Created)); } var buildChannel = new BuildChannel { Channel = channel, Build = build, DateTimeAdded = DateTimeOffset.UtcNow }; await _context.BuildChannels.AddAsync(buildChannel); await _context.SaveChangesAsync(); return(StatusCode((int)HttpStatusCode.Created)); }
void Start() { #if !RECOURCE_CLIENT foreach (ChannelConfig cc in sChannelConfigs.GetUnits().Values) { BuildPlatform bp = BuildPlatform.Windows; if (cc.Platform == "android") { bp = BuildPlatform.Android; } else if (cc.Platform == "ios") { bp = BuildPlatform.Ios; } BuildGroup bg = sBuildSettings.BuildGroups[(int)bp]; bool exist = false; foreach (BuildChannel bc in bg.Channels) { if (bc.ChannelName == cc.ChannelName) { exist = true; break; } } if (!exist) { BuildChannel bc = new BuildChannel(); bc.ChannelName = cc.ChannelName; bg.Channels.Add(bc); } } #endif var a = sBuildSettings; SaveSettings(); }
public async Task NoUpdateSubscriptionBecauseNotEnabled() { var channel = new Channel { Name = "channel", Classification = "class" }; var oldBuild = new Build { Branch = "source.branch", Repository = "source.repo", BuildNumber = "old.build.number", Commit = "oldSha", DateProduced = DateTimeOffset.UtcNow.AddDays(-2) }; var location = "https://source.feed/index.json"; var build = new Build { Branch = "source.branch", Repository = "source.repo", BuildNumber = "build.number", Commit = "sha", DateProduced = DateTimeOffset.UtcNow, Assets = new List <Asset> { new Asset { Name = "source.asset", Version = "1.0.1", Locations = new List <AssetLocation> { new AssetLocation { Location = location, Type = LocationType.NugetFeed } } } } }; var buildChannel = new BuildChannel { Build = build, Channel = channel }; var subscription = new Subscription { Channel = channel, SourceRepository = "source.repo", TargetRepository = "target.repo", TargetBranch = "target.branch", Enabled = false, PolicyObject = new SubscriptionPolicy { MergePolicies = null, UpdateFrequency = UpdateFrequency.EveryDay }, LastAppliedBuild = oldBuild }; var repoInstallation = new Repository { RepositoryName = "target.repo", InstallationId = 1 }; await Context.Repositories.AddAsync(repoInstallation); await Context.Subscriptions.AddAsync(subscription); await Context.BuildChannels.AddAsync(buildChannel); await Context.SaveChangesAsync(); SubscriptionActor.Verify(a => a.UpdateAsync(build.Id), Times.Never()); var updater = ActivatorUtilities.CreateInstance <DependencyUpdater>(Scope.ServiceProvider); await updater.CheckSubscriptionsAsync(CancellationToken.None); }
public static JToken CreateArgs(BuildChannel channel) { return(JToken.FromObject(new Arguments { BuildId = channel.BuildId, ChannelId = channel.ChannelId })); }
void OnGUI() { var style = new GUIStyle { fontSize = 18, }; var color = GUI.backgroundColor; var contentColor = GUI.contentColor; /* * //搜索框; * GUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar")); * var searchString = ""; * searchString = GUILayout.TextField(searchString, GUI.skin.FindStyle("ToolbarSeachTextField")); * if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton"))) * { * searchString = ""; * GUI.FocusControl(null); * } * GUILayout.EndHorizontal(); * * if (GUILayout.Button("File", EditorStyles.toolbarDropDown, GUILayout.Width(50))) * { * var menu = new GenericMenu(); * menu.AddItem(new GUIContent("设置"), false, () => * { * //LogHelper.PrintError("File->设置"); * }); * menu.ShowAsContext(); * } */ using (var v = new EditorGUILayout.VerticalScope(GUI.skin.window)) { using (var vv = new EditorGUILayout.VerticalScope(GUI.skin.window)) { using (var h = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("选择渠道:", style); GUILayout.Space(15); _buildChannel = (BuildChannel)EditorGUILayout.EnumPopup(_buildChannel); } GUILayout.Space(5); using (var h = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("选择目标平台:", style); GUILayout.Space(15); _buildPlatform = (BuildPlatform)EditorGUILayout.EnumPopup(_buildPlatform); } GUILayout.Space(5); using (var h = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("版本号:", style); GUILayout.Space(15); var release = _isRelease ? "1" : "0"; var versionCode = $"{_buildVersionCode.ToString()}.{release}"; var textColor = style.normal.textColor; style.normal.textColor = Color.red; EditorGUILayout.LabelField(versionCode, style); style.normal.textColor = textColor; } GUILayout.Space(10); using (var vvv = new EditorGUILayout.VerticalScope(GUI.skin.window)) { EditorGUILayout.LabelField("打游戏包", style); GUILayout.Space(5); using (var h = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("打包选项:", style); GUILayout.Space(15); _buildOptions = (BuildOptions)EditorGUILayout.EnumFlagsField(_buildOptions); } GUILayout.Space(5); using (var h = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("是否打Release包:", style); GUILayout.Space(15); bool curValue = _isRelease; _isRelease = EditorGUILayout.Toggle(_isRelease); if (_isRelease) { _buildOptions = BuildOptions.None; } else { if (curValue) { _buildOptions = BuildOptions.AllowDebugging | BuildOptions.Development; } } } GUILayout.Space(5); using (var h = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("打包资源完整完整包体:", style); GUILayout.Space(15); _isCompleteBuild = EditorGUILayout.Toggle(_isCompleteBuild); } GUILayout.Space(5); using (var h = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("重新打包AssetBundle:", style); GUILayout.Space(15); _isBuildAssetBundle = EditorGUILayout.Toggle(_isBuildAssetBundle); if (_isRelease) { _isBuildAssetBundle = true; } } GUILayout.Space(20); GUI.backgroundColor = Color.green; if (GUILayout.Button("开始打游戏包", GUILayout.Height(30))) { if (EditorUtility.DisplayDialog("提示", "确认开始打游戏包?", "确认")) { EditorApplication.delayCall += () => { CommandLineBuild(); }; Close(); } } GUI.backgroundColor = color; } GUILayout.Space(10); using (var vvv = new EditorGUILayout.VerticalScope(GUI.skin.window)) { EditorGUILayout.LabelField("打补丁包", style); GUILayout.Space(20); GUI.backgroundColor = Color.yellow; if (GUILayout.Button("开始打补丁包", GUILayout.Height(30))) { if (EditorUtility.DisplayDialog("提示", "确认开始打补丁包?", "确认")) { EditorApplication.delayCall += () => { }; Close(); } } GUI.backgroundColor = color; } } } }