<!DOCTYPE html> <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Build — python-copr 1.63 documentation</title> <script type="text/javascript" src="../../_static/js/modernizr.min.js"></script> <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script> <script type="text/javascript" src="../../_static/jquery.js"></script> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/language_data.js"></script> <script type="text/javascript" src="../../_static/js/theme.js"></script> <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <link rel="index" title="Index" href="../../genindex.html" /> <link rel="search" title="Search" href="../../search.html" /> <link rel="next" title="Build task" href="build_task.html" /> <link rel="prev" title="Project chroot" href="project_chroot.html" /> </head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > <a href="../../index.html" class="icon icon-home"> python-copr </a> <div class="version"> 1.63 </div> <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> <ul> <li class="toctree-l1"><a class="reference internal" href="../../installation.html">Installation</a></li> </ul> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../../ClientV1.html">Legacy client</a></li> <li class="toctree-l1 current"><a class="reference internal" href="../../ClientV2.html">Client version 2</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="../initialization.html">Client initialization</a></li> <li class="toctree-l2"><a class="reference internal" href="../resources_usage.html">Resources</a></li> <li class="toctree-l2"><a class="reference internal" href="../errors.html">Error handling</a></li> <li class="toctree-l2 current"><a class="reference internal" href="../../ClientV2.html#resources-info">Resources info</a><ul class="current"> <li class="toctree-l3"><a class="reference internal" href="project.html">Project</a></li> <li class="toctree-l3"><a class="reference internal" href="project_chroot.html">Project chroot</a></li> <li class="toctree-l3 current"><a class="current reference internal" href="#">Build</a><ul> <li class="toctree-l4"><a class="reference internal" href="#build-entity-attributes">Build entity attributes</a></li> <li class="toctree-l4"><a class="reference internal" href="#get-builds-list">Get builds list</a></li> <li class="toctree-l4"><a class="reference internal" href="#get-one-build">Get one build</a></li> <li class="toctree-l4"><a class="reference internal" href="#create-new-build">Create new build</a></li> <li class="toctree-l4"><a class="reference internal" href="#cancel-build">Cancel build</a></li> <li class="toctree-l4"><a class="reference internal" href="#delete-build">Delete build</a></li> </ul> </li> <li class="toctree-l3"><a class="reference internal" href="build_task.html">Build task</a></li> <li class="toctree-l3"><a class="reference internal" href="mock_chroot.html">Mock chroot</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="../../ClientV2.html#autodoc">Autodoc</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="../../ClientV3.html">Client version 3</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <nav class="wy-nav-top" aria-label="top navigation"> <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../index.html">python-copr</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="breadcrumbs navigation"> <ul class="wy-breadcrumbs"> <li><a href="../../index.html">Docs</a> »</li> <li><a href="../../ClientV2.html">Client version 2</a> »</li> <li>Build</li> <li class="wy-breadcrumbs-aside"> <a href="../../_sources/client_v2/resource_info/build.rst.txt" rel="nofollow"> View page source</a> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <div class="section" id="build"> <span id="build-info"></span><h1>Build<a class="headerlink" href="#build" title="Permalink to this headline">¶</a></h1> <p>Build resource allows to submit new builds and access current build progress. In fact, build consists of a few tasks, one per chroot, and detailed information is available through <a class="reference internal" href="build_task.html#build-task-info"><span class="std std-ref">Build task</span></a>.</p> <p>Access to the builds is done through <a class="reference internal" href="../general.html#copr.client_v2.client.CoprClient.builds" title="copr.client_v2.client.CoprClient.builds"><code class="xref py py-meth docutils literal notranslate"><span class="pre">builds()</span></code></a>. property of initialized <a class="reference internal" href="../general.html#copr.client_v2.client.CoprClient" title="copr.client_v2.client.CoprClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">CoprClient</span></code></a>. That property is an instance of <a class="reference internal" href="../handlers.html#copr.client_v2.handlers.BuildHandle" title="copr.client_v2.handlers.BuildHandle"><code class="xref py py-class docutils literal notranslate"><span class="pre">BuildHandle</span></code></a>.</p> <p>It may be more convenient to access builds in context of a project using method <a class="reference internal" href="../resources.html#copr.client_v2.resources.Project.get_builds" title="copr.client_v2.resources.Project.get_builds"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_builds()</span></code></a>.</p> <p>Builds are represented by <a class="reference internal" href="../resources.html#copr.client_v2.resources.Build" title="copr.client_v2.resources.Build"><code class="xref py py-class docutils literal notranslate"><span class="pre">Build</span></code></a> class.</p> <div class="section" id="build-entity-attributes"> <span id="build-attributes"></span><h2>Build entity attributes<a class="headerlink" href="#build-entity-attributes" title="Permalink to this headline">¶</a></h2> <table border="1" class="docutils"> <colgroup> <col width="15%" /> <col width="17%" /> <col width="68%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Field</th> <th class="head">Type</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>id</td> <td>int</td> <td>unique build identifier</td> </tr> <tr class="row-odd"><td>state</td> <td>string</td> <td>current state of the build, value is aggregated from build tasks</td> </tr> <tr class="row-even"><td>submitted_on</td> <td>int(unixtime UTC)</td> <td>time of the build submission</td> </tr> <tr class="row-odd"><td>started_on</td> <td>int(unixtime UTC)</td> <td>time when the first build task started, otherwise <code class="docutils literal notranslate"><span class="pre">null</span></code></td> </tr> <tr class="row-even"><td>ended_on</td> <td>int(unixtime UTC)</td> <td>time when the last build task ended, otherwise <code class="docutils literal notranslate"><span class="pre">null</span></code></td> </tr> <tr class="row-odd"><td>source_type</td> <td>string</td> <td>method used for build creation</td> </tr> <tr class="row-even"><td>source_metadata</td> <td>json object</td> <td>build source information</td> </tr> <tr class="row-odd"><td>package_version</td> <td>string</td> <td>version of the source package</td> </tr> <tr class="row-even"><td>package_name</td> <td>string</td> <td>name of the source package</td> </tr> <tr class="row-odd"><td>enable_net</td> <td>bool</td> <td>defines if network is available during the build</td> </tr> <tr class="row-even"><td>repos</td> <td>list of string</td> <td>list of additional repositories enabled during the build</td> </tr> <tr class="row-odd"><td>built_packages</td> <td>list of hash maps</td> <td>list of the built packages, each hash map has two keys: <code class="docutils literal notranslate"><span class="pre">name</span></code> and <code class="docutils literal notranslate"><span class="pre">version</span></code></td> </tr> <tr class="row-even"><td>submitter</td> <td>string</td> <td>name of the user who submitted the build</td> </tr> </tbody> </table> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Only the <code class="docutils literal notranslate"><span class="pre">state</span></code> field is editable by the PUT method. All other fields are read-only.</p> </div> </div> <div class="section" id="get-builds-list"> <h2>Get builds list<a class="headerlink" href="#get-builds-list" title="Permalink to this headline">¶</a></h2> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">blist_1</span> <span class="o">=</span> <span class="n">cl</span><span class="o">.</span><span class="n">builds</span><span class="o">.</span><span class="n">get_list</span><span class="p">(</span><span class="n">limit</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> <span class="gp">>>> </span><span class="k">print</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">blist_1</span><span class="p">))</span> <span class="go">['<Build #138426 state: succeeded>', '<Build #138425 state: succeeded>']</span> <span class="go"># using the project object</span> <span class="gp">>>> </span><span class="n">blist_2</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">get_builds</span><span class="p">(</span><span class="n">limit</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> <span class="gp">>>> </span><span class="k">print</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">blist_2</span><span class="p">))</span> <span class="go">['<Build #138423 state: failed>', '<Build #138421 state: failed>']</span> </pre></div> </div> </div> <div class="section" id="get-one-build"> <h2>Get one build<a class="headerlink" href="#get-one-build" title="Permalink to this headline">¶</a></h2> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">b</span> <span class="o">=</span> <span class="n">cl</span><span class="o">.</span><span class="n">builds</span><span class="o">.</span><span class="n">get_one</span><span class="p">(</span><span class="mi">138421</span><span class="p">)</span> <span class="gp">>>> </span><span class="k">print</span><span class="p">(</span><span class="n">b</span><span class="p">)</span> <span class="go"><Build #138421 state: failed></span> </pre></div> </div> </div> <div class="section" id="create-new-build"> <h2>Create new build<a class="headerlink" href="#create-new-build" title="Permalink to this headline">¶</a></h2> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># using the url to sprm</span> <span class="o">>>></span> <span class="n">b1</span> <span class="o">=</span> <span class="n">cl</span><span class="o">.</span><span class="n">builds</span><span class="o">.</span><span class="n">create_from_url</span><span class="p">(</span><span class="n">project_id</span><span class="o">=</span><span class="mi">3806</span><span class="p">,</span> <span class="n">srpm_url</span><span class="o">=</span><span class="s2">"http://example.com/my.src.rpm"</span><span class="p">)</span> <span class="c1"># or using project object</span> <span class="o">>>></span> <span class="n">b2</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">create_build_from_url</span><span class="p">(</span><span class="s2">"http://example.com/my.src.rpm"</span><span class="p">)</span> <span class="o">>>></span> <span class="k">print</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="p">[</span><span class="n">b1</span><span class="p">,</span> <span class="n">b2</span><span class="p">]))</span> <span class="p">[</span><span class="s1">'<Build #138431 state: importing>'</span><span class="p">,</span> <span class="s1">'<Build #138430 state: importing>'</span><span class="p">]</span> <span class="c1"># and using the file upload</span> <span class="o">>>></span> <span class="n">b3</span> <span class="o">=</span> <span class="n">cl</span><span class="o">.</span><span class="n">builds</span><span class="o">.</span><span class="n">create_from_file</span><span class="p">(</span><span class="n">project_id</span><span class="o">=</span><span class="mi">3806</span><span class="p">,</span> <span class="n">file_path</span><span class="o">=</span><span class="s2">"/tmp/hello-2.8-1.fc20.src.rpm"</span><span class="p">)</span> <span class="o">>>></span> <span class="n">b4</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">create_build_from_file</span><span class="p">(</span><span class="s2">"/tmp/hello-2.8-1.fc20.src.rpm"</span><span class="p">)</span> </pre></div> </div> </div> <div class="section" id="cancel-build"> <h2>Cancel build<a class="headerlink" href="#cancel-build" title="Permalink to this headline">¶</a></h2> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">b1</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span> </pre></div> </div> </div> <div class="section" id="delete-build"> <h2>Delete build<a class="headerlink" href="#delete-build" title="Permalink to this headline">¶</a></h2> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">b1</span><span class="o">.</span><span class="n">delete</span><span class="p">()</span> </pre></div> </div> </div> </div> </div> </div> <footer> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <a href="build_task.html" class="btn btn-neutral float-right" title="Build task" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="project_chroot.html" class="btn btn-neutral float-left" title="Project chroot" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> </div> <hr/> <div role="contentinfo"> <p> © Copyright 2018, Red Hat, Inc. </p> </div> Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script type="text/javascript"> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> </body> </html>