<?xml version='1.0' encoding='UTF-8'?>
<project>
  <actions/>
  <description>&lt;p&gt;&#xd;
Dynamically created job to generate apt and yum repos from packages built by jenkins. It uses the git archive from the package:tar cell in the upstream package matrix to determine which repos to create.&#xd;
&lt;/p&gt;&#xd;
&lt;p&gt;&#xd;
This job will trigger the downstream job supplied with DOWNSTREAM_JOB if passed to rake in the upstream invocation.&#xd;
&lt;/p&gt;&#xd;
</description>
  <logRotator class="hudson.tasks.LogRotator">
    <daysToKeep>3</daysToKeep>
    <numToKeep>-1</numToKeep>
    <artifactDaysToKeep>-1</artifactDaysToKeep>
    <artifactNumToKeep>-1</artifactNumToKeep>
  </logRotator>
  <keepDependencies>false</keepDependencies>
  <properties>
    <jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty plugin="hipchat-plugin@0.1.0">
      <room></room>
      <startNotification>false</startNotification>
    </jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty>
  </properties>
  <scm class="hudson.scm.NullSCM"/>
  <assignedNode>deb||rpm</assignedNode>
  <canRoam>false</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers class="vector"/>
  <concurrentBuild>false</concurrentBuild>
  <builders>
    <hudson.plugins.copyartifact.CopyArtifact plugin="copyartifact@1.25">
      <projectName><%= "#{Pkg::Config.project}-packaging-#{Pkg::Config.build_date}-#{Pkg::Config.ref}" %>/command=package_tar</projectName>
      <filter>**/PROJECT_BUNDLE, **/BUILD_PROPERTIES</filter>
      <target></target>
      <selector class="hudson.plugins.copyartifact.TriggeredBuildSelector">
        <fallbackToLastSuccessful>true</fallbackToLastSuccessful>
      </selector>
      <flatten>true</flatten>
    </hudson.plugins.copyartifact.CopyArtifact>
    <hudson.tasks.Shell>
      <command>#!/bin/bash
## We have to check if this has been triggered by a successful package build
curl -s &quot;http://<%= "#{Pkg::Config.jenkins_build_host}" %>/job/<%= "#{Pkg::Config.project}-packaging-#{Pkg::Config.build_date}-#{Pkg::Config.ref}" %>/lastBuild/api/json&quot; | grep result\&quot;:\&quot;SUCCESS\&quot; > /dev/null

PACKAGE_BUILD_RESULT=$?

set -e

if [ $PACKAGE_BUILD_RESULT -eq 0 ] ; then
  echo &quot;Detected upstream package build success. Building repos.&quot;
  ### We&apos;ve retrieved the git bundle from the tarball build, so now we clone it
  ### and use it to trigger our repo creation
  #
  # PROJECT_BUNDLE is a tarball containing a bundle file and git_repo is the
  # directory that will contain the git repository. First we untar the tarball
  # and then clone the git bundle

  [ -f &quot;PROJECT_BUNDLE&quot; ] || exit 1

  [ -f &quot;BUILD_PROPERTIES&quot; ] || exit 1

  [ -d project ] &amp;&amp; rm -rf project

  mkdir project &amp;&amp; tar -xzf PROJECT_BUNDLE -C project/

  pushd project
    git clone --recursive $(ls) git_repo

    pushd git_repo

      ### Clone the packaging repo
      bundle install --path .bundle/gems --binstubs .bundle/bin --retry 3

      ### Run repo creation
<% if Pkg::Config.final_mocks and not Pkg::Config.final_mocks.empty? %>
      bundle exec rake PARAMS_FILE=../../BUILD_PROPERTIES pl:jenkins:rpm_repos --trace
<% else %>
      echo "No mock/rpm targets found, skipping rpm repo creation"
<% end %>
<% if Pkg::Config.cows and not Pkg::Config.cows.empty? %>
      bundle exec rake PARAMS_FILE=../../BUILD_PROPERTIES pl:jenkins:deb_repos --trace
<% else %>
      echo "No cow/deb targets found, skipping deb repo creation"
<% end %>
    popd
  popd
else
  echo &quot;Detected upstream package build failure. Failing repo creation.&quot;
  exit 1
fi

</command>
    </hudson.tasks.Shell>
  </builders><% if ENV['DOWNSTREAM_JOB'] %>
  <publishers>
    <hudson.tasks.BuildTrigger>
      <childProjects><%= "#{Pkg::Config.project}-downstream-#{Pkg::Config.build_date}-#{Pkg::Config.ref}" %></childProjects>
      <threshold>
        <name>FAILURE</name>
        <ordinal>2</ordinal>
        <color>RED</color>
      </threshold>
    </hudson.tasks.BuildTrigger>
  </publishers><% else %>
  <publishers/><% end %>
  <buildWrappers>
    <hudson.plugins.ansicolor.AnsiColorBuildWrapper plugin="ansicolor@0.3.1">
      <colorMapName>xterm</colorMapName>
    </hudson.plugins.ansicolor.AnsiColorBuildWrapper>
    <hudson.plugins.timestamper.TimestamperBuildWrapper plugin="timestamper@1.8.4"/>
  </buildWrappers>
</project>