<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Zac&#039;s Blog &#187; powershell</title>
	<atom:link href="http://zacharyruiz.com/index.php/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://zacharyruiz.com</link>
	<description>on software...</description>
	<lastBuildDate>Sun, 06 Dec 2009 03:24:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>YouTrack Bugs from Anywhere with Powershell</title>
		<link>http://zacharyruiz.com/index.php/2009/10/youtrack-bugs-from-anywhere-with-powershell/</link>
		<comments>http://zacharyruiz.com/index.php/2009/10/youtrack-bugs-from-anywhere-with-powershell/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 18:14:54 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[youtrack]]></category>

		<guid isPermaLink="false">http://zacharyruiz.com/index.php/2009/10/youtrack-bugs-from-anywhere-with-powershell/</guid>
		<description><![CDATA[I really dig the new issue tracker from the JetBrains folks formerly codenamed Charisma.&#160; The in-browser experience is on the bleeding edge.
I spend a lot of time dreaming up or finding issues and bugs when I am not at my development machine.&#160; When this happens often times I do not want to launch YouTrack and [...]]]></description>
			<content:encoded><![CDATA[<p>I really dig the new <a href="http://www.jetbrains.com/youtrack/index.html">issue tracker from the JetBrains folks</a> formerly codenamed Charisma.&#160; The in-browser experience is on the bleeding edge.</p>
<p>I spend a lot of time dreaming up or finding issues and bugs when I am not at my development machine.&#160; When this happens often times I do not want to launch YouTrack and get stuck in; I would rather quickly log the issue and come back to it later to categorize, investigate or assign.&#160; </p>
<p>YouTrack has an <a href="http://www.jetbrains.net/devnet/thread/283385?tstart=0">undocumented REST API</a> for needs like this.&#160; I have ported their Java example to a quick and dirty powershell script:</p>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ab43f252-dafa-43f7-bada-3db1a051d121" class="wlWriterEditableSmartContent">
<pre style="background-color:Silver;overflow: auto;;font-family:Consolas;font-size:11.25"><span style="color: #0000FF;">param</span><span style="color: #000000;">(</span><span style="color: #800080;">$summary</span><span style="color: #000000;">, </span><span style="color: #800080;">$project</span><span style="color: #000000;">, </span><span style="color: #800080;">$usr</span><span style="color: #000000;">, </span><span style="color: #800080;">$pwd</span><span style="color: #000000;">, </span><span style="color: #800080;">$youtrack_url</span><span style="color: #000000;">)

</span><span style="color: #800080;">$cookies</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> new</span><span style="color: #000000;">-</span><span style="color: #000000;">object Net.CookieContainer

</span><span style="color: #0000FF;">function</span><span style="color: #000000;"> http</span><span style="color: #000000;">-</span><span style="color: #000000;">post([string]</span><span style="color: #800080;">$url</span><span style="color: #000000;">, [string]</span><span style="color: #800080;">$postData</span><span style="color: #000000;">) {
    </span><span style="color: #800080;">$buffer</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> [text.encoding]</span><span style="color: #000000;">::</span><span style="color: #000000;">ascii.getbytes(</span><span style="color: #800080;">$postData</span><span style="color: #000000;">)
    [net.httpWebRequest] </span><span style="color: #800080;">$req</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> [net.webRequest]</span><span style="color: #000000;">::</span><span style="color: #000000;">create(</span><span style="color: #800080;">$url</span><span style="color: #000000;">)
    </span><span style="color: #800080;">$req</span><span style="color: #000000;">.method </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">POST</span><span style="color: #800000;">"</span><span style="color: #000000;">
    </span><span style="color: #800080;">$req</span><span style="color: #000000;">.ContentType </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">application/x-www-form-urlencoded</span><span style="color: #800000;">"</span><span style="color: #000000;">
    </span><span style="color: #800080;">$req</span><span style="color: #000000;">.ContentLength </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$buffer</span><span style="color: #000000;">.length
    </span><span style="color: #800080;">$req</span><span style="color: #000000;">.TimeOut </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">5000</span><span style="color: #000000;">
    </span><span style="color: #800080;">$req</span><span style="color: #000000;">.CookieContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$cookies</span><span style="color: #000000;">
    </span><span style="color: #800080;">$reqst</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$req</span><span style="color: #000000;">.getRequestStream()
    </span><span style="color: #800080;">$reqst</span><span style="color: #000000;">.write(</span><span style="color: #800080;">$buffer</span><span style="color: #000000;">, </span><span style="color: #000000;">0</span><span style="color: #000000;">, </span><span style="color: #800080;">$buffer</span><span style="color: #000000;">.length)
    </span><span style="color: #800080;">$reqst</span><span style="color: #000000;">.flush()
    </span><span style="color: #800080;">$reqst</span><span style="color: #000000;">.close()
    [net.httpWebResponse] </span><span style="color: #800080;">$res</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$req</span><span style="color: #000000;">.getResponse()
    </span><span style="color: #800080;">$resst</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$res</span><span style="color: #000000;">.getResponseStream()
    </span><span style="color: #800080;">$sr</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> new</span><span style="color: #000000;">-</span><span style="color: #000000;">object IO.StreamReader(</span><span style="color: #800080;">$resst</span><span style="color: #000000;">)
    </span><span style="color: #800080;">$results</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$sr</span><span style="color: #000000;">.ReadToEnd()
    </span><span style="color: #008000;">#</span><span style="color: #008000;"> save cookies for next request</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;">(</span><span style="color: #800080;">$cookie</span><span style="color: #000000;"> </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> </span><span style="color: #800080;">$res</span><span style="color: #000000;">.Cookies) {
        </span><span style="color: #800080;">$cookies</span><span style="color: #000000;">.Add(</span><span style="color: #800080;">$cookie</span><span style="color: #000000;">)
    }
    </span><span style="color: #800080;">$results</span><span style="color: #000000;">
}

</span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (([xml](http</span><span style="color: #000000;">-</span><span style="color: #000000;">post </span><span style="color: #800000;">"</span><span style="color: #800000;">$youtrack_url/rest/user/login</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">login=$usr&amp;password=$pwd</span><span style="color: #800000;">"</span><span style="color: #000000;">)).login </span><span style="color: #008080;">-match</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">ok</span><span style="color: #800000;">"</span><span style="color: #000000;">) {
    </span><span style="color: #800080;">$id</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> ([xml](http</span><span style="color: #000000;">-</span><span style="color: #000000;">post </span><span style="color: #800000;">"</span><span style="color: #800000;">$youtrack_url/rest/issue</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">project=$project&amp;summary=$summary</span><span style="color: #800000;">"</span><span style="color: #000000;">)).issue.id[</span><span style="color: #000000;">0</span><span style="color: #000000;">]
    </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">issue $id created in youtrack...</span><span style="color: #800000;">"</span><span style="color: #000000;">
}
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>I look forward to refactoring this script into a full featured library as the need arises and the YouTrack REST API becomes documented.&#160; </p>
<p>In the meantime I keep this script on my portable USB drive.&#160; I have a home grown application launcher that I like to use to execute scripts like the one above.</p>
<p><a href="http://zacharyruiz.com/wp-content/uploads/2009/10/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://zacharyruiz.com/wp-content/uploads/2009/10/image_thumb.png" width="509" height="354" /></a></p>
<p>So when I am in the lab being a “user” and I find a bug, I just type “&lt;project code&gt; bug &lt;summary&gt;” as illustrated above and a new issue will be opened in YouTrack.&#160; Later in the afternoon when I am at my desk being a “developer” I can fire up YouTrack and take it from there. </p>
]]></content:encoded>
			<wfw:commentRss>http://zacharyruiz.com/index.php/2009/10/youtrack-bugs-from-anywhere-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->