Asset Server - Manual commit from script

Hi,
In order to finish the continuous integration of our project, I need to submit nightly-builded libs into our unity asset server.

Is there a way to submit something into the UAS from code (c# or script(python/bash)) ?

That is quite a basic operation, a simple submit, but I haven’t seen anything like that in the doc and it is really missing.

Could this be done in command line with psql ?

Could this be done by faking a click in “commit” button in the UnityEditor.ASMainWindow ?

Cheers,

Ok - After some investigation with ILspy, here is the solution I came up with.

It is certainly not perfect, using Reflection to call on private members, but well, it gets the job done.

The code will certainly break if the UnityTeam decides to changes internal names,

Hope that can be useful to some of you,

	static void UASCommit ( string[] _files, string _messageCommit )
	{   
		if (    _files == null
			 || _files.Length == 0
			 || string.IsNullOrEmpty( _messageCommit ) )
		{
			Debug.Log ( "UASCommit -- Invalid Arguments." );
			return;
		}
		
		string menuPath = "Window/Asset Server";
		string defaultTitle = "Server";
		System.Reflection.Assembly assembly =  typeof(UnityEditor.EditorWindow).Assembly;
        System.Type type = assembly.GetType( "UnityEditor.ASMainWindow" );
		
		EditorApplication.ExecuteMenuItem(menuPath);
        EditorWindow window = EditorWindow.GetWindow(type, false, defaultTitle);
		             
		try
		{ 
			List<UnityEngine.Object> selectionList = new List<UnityEngine.Object>();
			foreach ( string file in _files )
			{
				UnityEngine.Object assetFromFile = AssetDatabase.LoadMainAssetAtPath( file ) ;
				if ( assetFromFile != null )
				{
					selectionList.Add ( assetFromFile );
				}
			}
			 
			Selection.objects = selectionList.ToArray();
			if (Selection.objects.Length != _files.Length)
			{
				Debug.LogError(
					string.Format( "Selection size is incorrect. Selection has '{0}' items whereas we asked for '{1}' files to be submitted.",
						Selection.objects.Length, _files.Length ) );
				
				return;
			}
			
			type.InvokeMember("StartCommitting", 
				System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic 
				, null, window, null); 
						
			// set value of private field: private double _number
			type.InvokeMember("commitMessage",
			    BindingFlags.SetField | BindingFlags.Instance | BindingFlags.NonPublic,
			    null, window, new string[] { _messageCommit } ); 
			     
			type.InvokeMember("DoCommit", 
				System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic 
				, null, window, null);
			 
		}
		catch ( System.Reflection.TargetInvocationException targetInvocationException )
		{
			if ( targetInvocationException.InnerException is UnityEngine.ExitGUIException )
			{ 
				// Do Commit finish by a "GUIUtility.ExitGUI();"
				//
				// UnityEngine.GUIUtility
				// public static void ExitGUI()
				// {
				// 		throw new ExitGUIException();
				// }
				// 
				// So appenrently that is "normal" to throw an exception -
	 			// Well, I am going to eat it silently 
			}
			else
			{
				Debug.LogError ( targetInvocationException.InnerException.Message );
				throw targetInvocationException.InnerException;
			}
		}
	}