JenkinsUtility 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package JenkinsUtility --version 1.0.0                
NuGet\Install-Package JenkinsUtility -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JenkinsUtility" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JenkinsUtility --version 1.0.0                
#r "nuget: JenkinsUtility, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install JenkinsUtility as a Cake Addin
#addin nuget:?package=JenkinsUtility&version=1.0.0

// Install JenkinsUtility as a Cake Tool
#tool nuget:?package=JenkinsUtility&version=1.0.0                
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.IO;
using System.Net;

namespace JenkinsUtilityTester
{
	public partial class JenkinsUtilityTester : Form
	{
		public JenkinsUtilityTester()
		{
			var statusStrip = new StatusStrip() { Parent = this, };

			ToolStripStatusLabel toolStripStatusLabel = new ToolStripStatusLabel()
			{
				Text = "Ready",
				Spring = true,
				TextAlign = ContentAlignment.MiddleLeft,
			};

			statusStrip.Items.Add(toolStripStatusLabel);

			TabControl tabControl = new TabControl() { Parent = this, Dock = DockStyle.Top, };
			tabControl.ContextMenuStrip = new ContextMenuStrip();
			ToolStripMenuItem toolStripMenuItemRemoveTab = new ToolStripMenuItem() { Text = "Remove selected tab", };
			toolStripMenuItemRemoveTab.Click += (sender, e) =>
			{
				var st = tabControl.SelectedTab;
				if (st != default(TabPage))
				{
					tabControl.TabPages.Remove(st);
				}
			};
			tabControl.ContextMenuStrip.Items.Add(toolStripMenuItemRemoveTab);

			MenuStrip menuStrip = new MenuStrip() { Parent = this, };
			ToolStripMenuItem toolStripMenuItemFile = new ToolStripMenuItem() { Text = "File", };

			Action<JenkinsUtility.JenkinsUtility> addConnection = (ju) =>
			{
				TabPage page = new TabPage() { Text = ju.Project, };

				Panel panel2 = new Panel() { Parent = page, Dock = DockStyle.Left, };
				ListView listViewBuildResult = new ListView()
				{
					Parent = panel2,
					Dock = DockStyle.Top,
					FullRowSelect = true,
					HideSelection = false,
					View = View.Details
				};

				listViewBuildResult.ContextMenuStrip = new ContextMenuStrip();
				ToolStripMenuItem toolStripMenuItemDownloadSelected = new ToolStripMenuItem() { Text = "Download selected artifacts", };
				listViewBuildResult.ContextMenuStrip.Items.Add(toolStripMenuItemDownloadSelected);
				listViewBuildResult.ContextMenuStrip.Items.Add(new ToolStripSeparator());
				ToolStripMenuItem toolStripMenuItemViewSelected = new ToolStripMenuItem() { Text = "View selected artifacts", };
				listViewBuildResult.ContextMenuStrip.Items.Add(toolStripMenuItemViewSelected);

				listViewBuildResult.Columns.AddRange(new[]
				{
					new ColumnHeader(){ Text="Item name", },
					new ColumnHeader(){ Text="Value",},
				});

				Panel panel3 = new Panel() { Parent = panel2, Dock = DockStyle.Top, Height = new Label().Height };
				Button buttonResetFilter = new Button() { Text = "Reset filter", Dock = DockStyle.Right, AutoSize = true, };
				Button buttonFilterParameters = new Button() { Text = "Filter parameter", Dock = DockStyle.Right, AutoSize = true, };
				Button buttonFilterArtifacts = new Button() { Text = "Filter artifacts", Dock = DockStyle.Right, AutoSize = true, };

				panel3.Controls.AddRange(new[] { buttonResetFilter, buttonFilterParameters, buttonFilterArtifacts });

				panel3.Controls.Add(new Label() { Dock = DockStyle.Left, Text = "Build result", AutoSize = true, });

				panel2.Controls.Add(panel3);// new Label() { Dock = DockStyle.Top, Text = "Build result", });


				Panel panel1 = new Panel() { Parent = page, Dock = DockStyle.Left, };
				ListView listViewBuilds = new ListView()
				{
					Parent = panel1,
					Dock = DockStyle.Top,
					FullRowSelect = true,
					HideSelection = false,
					View = View.Details
				};
				listViewBuilds.Columns.Add(new ColumnHeader() { Text = "Build No", });
				var labelBuild = new Label() { Dock = DockStyle.Top, Text = "Build No", };


				toolStripMenuItemDownloadSelected.Click += async (sender, e) =>
				{
					if (ju != null)
					{
						var si = listViewBuilds.SelectedItems.Cast<ListViewItem>().FirstOrDefault();
						if (si != default(ListViewItem))
						{
							var bn = si.Text;
							var dlcount = 0;
							var dllist = listViewBuildResult.SelectedItems.Cast<ListViewItem>().Select(x => x.SubItems[1].Text).ToList();
							foreach (var p in dllist)
							{
								var dp = await ju.DownloadArtifact(bn, p, Application.StartupPath);
								if (!string.IsNullOrEmpty(dp))
								{
									dlcount++;
								}
							}
							toolStripStatusLabel.Text = string.Format("Downloaded: {0}", dlcount);
						}
					}
				};

				toolStripMenuItemViewSelected.Click += async (sender, e) =>
				{
					if (ju != null)
					{
						var si = listViewBuilds.SelectedItems.Cast<ListViewItem>().FirstOrDefault();
						if (si != default(ListViewItem))
						{
							var bn = si.Text;
							var dllist = listViewBuildResult.SelectedItems.Cast<ListViewItem>().Select(x => x.SubItems[1].Text).ToList();
							foreach (var p in dllist)
							{
								var d = await ju.GetArtifact(bn, p);
								MessageBox.Show(Encoding.UTF8.GetString(d));
							}
						}
					}
				};

				ToolStripMenuItem toolStripMenuItemDownloadAll = new ToolStripMenuItem() { Text = "Download all artifacts", };
				toolStripMenuItemDownloadAll.Click += async (sender, e) =>
				 {
					 if (ju != null)
					 {
						 foreach (var si in listViewBuilds.SelectedItems.Cast<ListViewItem>())
						 {
							 var bn = si.Text;
							 var list = ju.GetArtifactsList(bn);
							 foreach (var l in list)
							 {
								 await ju.DownloadArtifact(bn, l, Application.StartupPath);
							 }
						 }
					 }
				 };

				ToolStripMenuItem toolStripMenuItemReBuild = new ToolStripMenuItem() { Text = "Rebuild using same parameters of selected build", };
				toolStripMenuItemReBuild.Click += async (sender, e) =>
				{
					if (ju != null)
					{
						var sb = listViewBuilds.SelectedItems.Cast<ListViewItem>().FirstOrDefault();
						if (sb != default(ListViewItem))
						{
							var bn = sb.Text;
							var r = await ju.ReBuild(bn);
							MessageBox.Show(r);
						}
					}
				};

				ToolStripMenuItem toolStripMenuItemDeleteBuilds = new ToolStripMenuItem() { Text = "Delete selected builds", };
				toolStripMenuItemDeleteBuilds.Click += (sender, e) =>
				{
					if (ju != null)
					{
						var sb = listViewBuilds.SelectedItems.Cast<ListViewItem>().FirstOrDefault();
						if (sb != default(ListViewItem))
						{
							var bn = sb.Text;
							if (MessageBox.Show(string.Format("Delete build: {0}?", bn), "Delete Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
							{
								var r = ju.DeleteBuild(bn);
								MessageBox.Show(r);
							}
						}
					}
				};



				listViewBuilds.ContextMenuStrip = new ContextMenuStrip();
				listViewBuilds.ContextMenuStrip.Items.Add(toolStripMenuItemDownloadAll);
				listViewBuilds.ContextMenuStrip.Items.Add(new ToolStripSeparator());
				listViewBuilds.ContextMenuStrip.Items.Add(toolStripMenuItemReBuild);
				listViewBuilds.ContextMenuStrip.Items.Add(new ToolStripSeparator());
				listViewBuilds.ContextMenuStrip.Items.Add(toolStripMenuItemDeleteBuilds);



				panel1.Controls.Add(labelBuild);

				ToolStrip toolStrip = new ToolStrip() { Parent = page, Dock = DockStyle.Top, };

				ToolStripButton toolStripButtonGetAllBuilds = new ToolStripButton() { Text = "Get job status" };
				toolStripButtonGetAllBuilds.Click += (sender, e) =>
				{
					/** GetAllBuildsAsDic returns many info*/
					var dic = ju.GetAllBuildsAsDic(1);
					if (dic.Count > 0)
					{
						MessageBox.Show(string.Join(Environment.NewLine, dic.Where(x => x.Key.EndsWith(".number")).Select(x => string.Format("{0}={1}", x.Key, x.Value))));
					}
				};

				Func<int, Task> GetLatest = async (n) =>
				 {
					 Enabled = false;
					 if (ju != null)
					 {
						 var builds = await ju.GetLatestBuilds(n);

						 listViewBuildResult.Items.Clear();

						 listViewBuilds.BeginUpdate();
						 listViewBuilds.Items.Clear();
						 if (builds.Count > 0)
						 {
							 listViewBuilds.Items.AddRange(builds.Select(x => new ListViewItem() { Text = x.ToString(), }).ToArray());
						 }
						 listViewBuilds.EndUpdate();
					 }

					 toolStripStatusLabel.Text = "Ready";
					 Enabled = true;
				 };

				ToolStripButton toolStripButtonBuild = new ToolStripButton() { Text = "Build", };
				toolStripButtonBuild.Click += (sender2, e2) => { ju.Build(); };

				ToolStripButton toolStripButtonGetLatestBuilds10 = new ToolStripButton() { Text = "Get latest 10 builds", };
				toolStripButtonGetLatestBuilds10.Click += async (sender2, e2) => { await GetLatest(10); };

				ToolStripButton toolStripButtonGetLatestBuilds30 = new ToolStripButton() { Text = "Get latest 30 builds", };
				toolStripButtonGetLatestBuilds30.Click += async (sender2, e2) => { await GetLatest(30); };


				ToolStripButton toolStripButtonSave = new ToolStripButton() { Text = "Save Setting", };
				toolStripButtonSave.Click += (sender2, e2) =>
				{
					/** 
					 * Save connection setting. Password is encrypted using default aes_iv, aes_key.
					 * If you want to change those, then set as below when application start.
					 * JenkinsUtility.JenkinsUtility.AES_IV = "AsYouLike";
					 * JenkinsUtility.JenkinsUtility.AES_KEY = "AsYouLike";
					 */

					ju.Save();
				};

				ToolStripButton toolStripButtonEditSetting = new ToolStripButton() { Text = "Edit Setting", };
				toolStripButtonEditSetting.Click += (sender2, e2) => { ju.Edit(); };


				Action<string> getBuildResult = (filter) =>
				{
					listViewBuildResult.BeginUpdate();
					listViewBuildResult.Items.Clear();
					var si = listViewBuilds.SelectedItems.Cast<ListViewItem>().FirstOrDefault();
					if (si != default(ListViewItem))
					{
						var bn = si.Text;
						var r = ju.GetBuildResult(bn);
						if (r != default(Dictionary<string, object>))
						{
							var lr = string.IsNullOrEmpty(filter) ? r : r.Where(x => x.Key.Contains(filter));
							foreach (var kv in lr)
							{
								listViewBuildResult.Items.Add(new ListViewItem(new[] { kv.Key, kv.Value.ToString() }));
							}
						}
					}
					listViewBuildResult.EndUpdate();
				};
				buttonFilterParameters.Click += (sender, e) => { getBuildResult(".parameters"); };
				buttonFilterArtifacts.Click += (sender, e) => { getBuildResult(".relativePath"); };
				buttonResetFilter.Click += (sender, e) => { getBuildResult(null); };

				listViewBuilds.SelectedIndexChanged += (sender2, e2) =>
				{
					getBuildResult(null);
				};

				page.SizeChanged += (sender2, e2) =>
				{
					tabControl.Height = ClientSize.Height - menuStrip.Height - statusStrip.Height;
					panel1.Width = 100;
					panel2.Width = page.Width - panel1.Width;

					listViewBuilds.Height = listViewBuildResult.Height = page.ClientSize.Height - toolStrip.Height - labelBuild.Height;

					listViewBuilds.Columns.Cast<ColumnHeader>().ToList().ForEach(x => x.Width = listViewBuilds.ClientSize.Width / listViewBuilds.Columns.Count);
					listViewBuildResult.Columns.Cast<ColumnHeader>().ToList().ForEach(x => x.Width = listViewBuildResult.ClientSize.Width / listViewBuildResult.Columns.Count);

				};

				toolStrip.Items.Add(toolStripButtonBuild);
				toolStrip.Items.Add(new ToolStripSeparator());
				toolStrip.Items.Add(toolStripButtonGetLatestBuilds10);
				toolStrip.Items.Add(toolStripButtonGetLatestBuilds30);

				toolStrip.Items.Add(new ToolStripSeparator());
				toolStrip.Items.Add(toolStripButtonGetAllBuilds);
				toolStrip.Items.Add(new ToolStripSeparator());
				toolStrip.Items.Add(toolStripButtonEditSetting);
				toolStrip.Items.Add(toolStripButtonSave);


				tabControl.TabPages.Add(page);
				tabControl.SelectTab(page);


			};

			ToolStripMenuItem toolStripMenuItemCreate = new ToolStripMenuItem() { Text = "New", };
			toolStripMenuItemCreate.Click += (sender, e) =>
			{
				var ju = JenkinsUtility.JenkinsUtility.Create();
				if (ju != null)
				{
					/** If you want to show progress, set progress */
					ju.Progress = (v) => { toolStripStatusLabel.Text = v; };
					addConnection(ju);
				}
			};

			ToolStripMenuItem toolStripMenuItemOpen = new ToolStripMenuItem() { Text = "Open", };
			toolStripMenuItemOpen.Click += (sender, e) =>
			{
				var ju = JenkinsUtility.JenkinsUtility.Open();
				if (ju != null)
				{
					/** Progress is not saved, so set progress again */
					ju.Progress = (v) => { toolStripStatusLabel.Text = v; };
					addConnection(ju);
				}
			};


			toolStripMenuItemFile.DropDownItems.Add(toolStripMenuItemCreate);
			toolStripMenuItemFile.DropDownItems.Add(toolStripMenuItemOpen);

			menuStrip.Items.Add(toolStripMenuItemFile);

			Font = SystemInformation.MenuFont;
			StartPosition = FormStartPosition.CenterScreen;

			SizeChanged += (sender, e) =>
			{
				tabControl.Height = ClientSize.Height - menuStrip.Height - statusStrip.Height;
			};
			ClientSize = new Size(1000, 600);
			Text = "JenkinsUtilityTester";
		}
	}
}
Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 99 11/21/2024
1.0.5 92 11/20/2024
1.0.0 125 7/15/2024