<div class="content-detail markdown-body">
<pre class="blockcode"><span style="color:#75715e;">#-*- coding:utf-8 -*-<br></span><span style="color:#66d9ef;font-style:italic;">from </span>case.beatles.test_beatles <span style="color:#66d9ef;font-style:italic;">import </span>TestBeatles<br><span style="color:#66d9ef;font-style:italic;">from </span>framework.logger <span style="color:#66d9ef;font-style:italic;">import </span>Logger<br><span style="color:#66d9ef;font-style:italic;">from </span>page.ios.beatles.jenkins_page <span style="color:#66d9ef;font-style:italic;">import </span>Jenkins_Tool<br><br><span style="color:#66d9ef;font-style:italic;">class </span><span style="color:#a6e22e;">DownloadApp</span>(TestBeatles)<span style="color:#f92672;">:<br></span><span style="color:#f92672;"><br></span><span style="color:#f92672;"> </span><span style="color:#66d9ef;font-style:italic;">def </span><span style="color:#a6e22e;">testDownloadfromJenkins</span>(<span style="color:#94558d;">self</span>)<span style="color:#f92672;">:<br></span><span style="color:#f92672;"> </span><span style="color:#66d9ef;font-style:italic;">try</span><span style="color:#f92672;">:<br></span><span style="color:#f92672;"> </span>jp <span style="color:#f92672;">= </span><span style="color:#66d9ef;">Jenkins_Tool</span>()<br>
jp.<span style="color:#66d9ef;">download_app_from_jenkins</span>()<br><span style="color:#66d9ef;font-style:italic;">except </span><span style="color:#66d9ef;">Exception</span><span style="color:#cc7832;">, </span>e<span style="color:#f92672;">:<br></span><span style="color:#f92672;"> </span>Logger.<span style="color:#66d9ef;">error</span>(e)<br><span style="color:#94558d;">self</span>.<span style="color:#66d9ef;">save_screenshot</span>()<br><span style="color:#94558d;">self</span>.<span style="color:#66d9ef;">fail</span>(e.message)</pre>
<p><br></p>
<p><br></p>
<pre class="blockcode"><span style="color:#75715e;">#-*- coding:utf-8 -*-<br></span><span style="color:#66d9ef;font-style:italic;">from </span>datetime <span style="color:#66d9ef;font-style:italic;">import </span>datetime<br><span style="color:#66d9ef;font-style:italic;">import </span>urllib<br><span style="color:#66d9ef;font-style:italic;">import </span>jenkins<br><span style="color:#66d9ef;font-style:italic;">import </span>os<br><br>
job_names <span style="color:#f92672;">= </span>[<span style="color:#a5c261;">'job-ios'</span><span style="color:#cc7832;">,</span><span style="color:#a5c261;">'job_android'</span>]<br>
username <span style="color:#f92672;">= </span><span style="color:#a5c261;">'Jenkins用户名'<br></span>password <span style="color:#f92672;">= </span><span style="color:#a5c261;">'Jenkins密码'<br></span>base_ios_debug_download_url <span style="color:#f92672;">= </span><span style="color:#a5c261;">'https://xxx/ios/Debug/'<br></span>base_android_debug_download_url <span style="color:#f92672;">= </span><span style="color:#a5c261;">'https://xxx/android/Debug/'<br></span>ios_app_suffix <span style="color:#f92672;">= </span><span style="color:#a5c261;">'.ipa'<br></span><span style="color:#a5c261;"><br></span><span style="color:#66d9ef;font-style:italic;">class </span><span style="color:#a6e22e;">Jenkins_Tool</span>()<span style="color:#f92672;">:<br></span><span style="color:#f92672;"> <br></span><span style="color:#f92672;"> </span><span style="color:#66d9ef;font-style:italic;">def __init__</span>(<span style="color:#94558d;">self</span>)<span style="color:#f92672;">:<br></span><span style="color:#f92672;"> </span><span style="color:#94558d;">self</span>.jenkins_url <span style="color:#f92672;">= </span><span style="color:#a5c261;">'http://jenkins host url'<br></span><span style="color:#a5c261;"> </span><span style="color:#94558d;">self</span>.sever <span style="color:#f92672;">= </span>jenkins.<span style="color:#66d9ef;">Jenkins</span>(<span style="color:#94558d;">self</span>.jenkins_url<span style="color:#cc7832;">, </span><span style="color:#aa4926;">username</span><span style="color:#f92672;">=</span>username<span style="color:#cc7832;">, </span><span style="color:#aa4926;">password</span><span style="color:#f92672;">=</span>password)<br><br><span style="color:#75715e;"># 获取最新构建号<br></span><span style="color:#75715e;"> </span><span style="color:#66d9ef;font-style:italic;">def </span><span style="color:#a6e22e;">get_build_number</span>(<span style="color:#94558d;">self</span><span style="color:#cc7832;">, </span><span style="color:#fd971f;font-style:italic;">job_name</span>)<span style="color:#f92672;">:<br></span><span style="color:#f92672;"> </span>lastest_completed_build_number <span style="color:#f92672;">= </span><span style="color:#94558d;">self</span>.sever.<span style="color:#66d9ef;">get_job_info</span>(<span style="color:#fd971f;font-style:italic;">job_name</span>)[<span style="color:#a5c261;">'lastCompletedBuild'</span>][<span style="color:#a5c261;">'number'</span>]<br><span style="color:#75715e;"># print(lastest_completed_build_number)<br></span><span style="color:#75715e;"> </span><span style="color:#66d9ef;font-style:italic;">return </span>lastest_completed_build_number<br><br><span style="color:#75715e;"># 获取Jenkins下的所有job<br></span><span style="color:#75715e;"> </span><span style |
|