private void AddScriptNode()

in tool/TeamCity.Docker/ScriptsGenerator.cs [71:86]


        private void AddScriptNode(IGraph<IArtifact, Dependency> graph, INode<IArtifact> node, string newLine, string header, string extension)
        {
            var image = (Image) node.Value;
            var lines = new List<string>();
            var scriptFileName = $"{image.File.ImageId}-{image.File.Tags.First()}{extension}";
            var root = string.Join("/", Enumerable.Repeat("..", _options.TargetPath.Split('\\', '/').Length));
            if (!string.IsNullOrWhiteSpace(header))
            {
                lines.Add(header);
            }

            lines.Add($"cd {root}");
            lines.AddRange(_scriptGenerator.GenerateScript(graph, node, _ => true));
            var scriptFilePath = _pathService.Normalize(Path.Combine(_options.TargetPath, scriptFileName));
            graph.TryAddNode(new FileArtifact(scriptFilePath, new[] {string.Join(newLine, lines)}), out var _);
        }