<?xml version='1.1' encoding='UTF-8'?>
<project>
  <actions/>
  <description>Image creation jobs for all kinds of images</description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <hudson.plugins.buildblocker.BuildBlockerProperty plugin="build-blocker-plugin@1.7.3">
      <useBuildBlocker>false</useBuildBlocker>
      <blockLevel>UNDEFINED</blockLevel>
      <scanQueueFor>DISABLED</scanQueueFor>
      <blockingJobs></blockingJobs>
    </hudson.plugins.buildblocker.BuildBlockerProperty>
    <com.cloudbees.plugins.JobPrerequisites plugin="slave-prerequisites@1.0">
      <script>mnt_point_cnt=`sudo df -hT | grep /dev/loop | awk &apos;{print $1}&apos; | wc -l`
loop_device_cnt=`sudo losetup -a | awk &apos;{print $1}&apos; | wc -l`
if [ $mnt_point_cnt -gt 0 ]; then
  exit 1;
fi
if [ $loop_device_cnt -gt 0 ]; then
  exit 2;
fi
curr_free=`sudo df -h / | grep dev | awk &apos;{print $4}&apos; | sed &apos;s/[^0-9.]*//g&apos;`
var=$(awk &apos;BEGIN{ print &quot;&apos;$curr_free&apos;&quot;&lt;&quot;&apos;3.0&apos;&quot; }&apos;)
if [ &quot;$var&quot; -eq 1 ];then
  exit 3;
fi

exit 0</script>
      <interpreter>shell script</interpreter>
    </com.cloudbees.plugins.JobPrerequisites>
    <com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.28">
      <autoRebuild>false</autoRebuild>
      <rebuildDisabled>false</rebuildDisabled>
    </com.sonyericsson.rebuild.RebuildSettings>
    <jenkins.model.BuildDiscarderProperty>
      <strategy class="hudson.tasks.LogRotator">
        <daysToKeep>3</daysToKeep>
        <numToKeep>-1</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
      </strategy>
    </jenkins.model.BuildDiscarderProperty>
    <hudson.model.ParametersDefinitionProperty>
      <parameterDefinitions>
        <hudson.model.StringParameterDefinition>
          <name>TRIGGER_INFO</name>
          <description></description>
          <defaultValue></defaultValue>
          <trim>false</trim>
        </hudson.model.StringParameterDefinition>
      </parameterDefinitions>
    </hudson.model.ParametersDefinitionProperty>
  </properties>
  <scm class="hudson.scm.NullSCM"/>
  <assignedNode>imager</assignedNode>
  <canRoam>false</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers/>
  <concurrentBuild>true</concurrentBuild>
  <builders>
    <hudson.tasks.Shell>
      <command>#/bin/bash

export MIC_WORK_DIR=/var/tmp/mic_$BUILD_NUMBER
export MIC_CONF_FILE=$MIC_WORK_DIR/mic.conf
mkdir -p $MIC_WORK_DIR
cp /etc/mic/mic.conf $MIC_CONF_FILE
sed -i &quot;s|^tmpdir= /var/tmp/mic|tmpdir= $MIC_WORK_DIR|g&quot; $MIC_CONF_FILE
sed -i &quot;s|^cachedir= /var/tmp/mic/cache|cachedir= $MIC_WORK_DIR/cache|g&quot; $MIC_CONF_FILE
sed -i &quot;s|^rootdir=/var/tmp/mic-bootstrap|rootdir= $MIC_WORK_DIR/mic-bootstrap|g&quot; $MIC_CONF_FILE

python ${WORKSPACE}/jenkins-scripts/job_gbsfullbuild_image_creator.py</command>
    </hudson.tasks.Shell>
  </builders>
  <publishers>
    <hudson.plugins.parameterizedtrigger.BuildTrigger plugin="parameterized-trigger@2.35.2">
      <configs>
        <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
          <configs>
            <hudson.plugins.parameterizedtrigger.FileBuildParameters>
              <propertiesFile>POST-IMAGE-CREATION.env</propertiesFile>
              <failTriggerOnMissing>true</failTriggerOnMissing>
              <textParamValueOnNewLine>false</textParamValueOnNewLine>
              <useMatrixChild>false</useMatrixChild>
              <onlyExactRuns>false</onlyExactRuns>
            </hudson.plugins.parameterizedtrigger.FileBuildParameters>
          </configs>
          <projects>post-image-creation</projects>
          <condition>ALWAYS</condition>
          <triggerWithNoParameters>false</triggerWithNoParameters>
          <triggerFromChildProjects>false</triggerFromChildProjects>
        </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
        <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
          <configs>
            <hudson.plugins.parameterizedtrigger.FileBuildParameters>
              <propertiesFile>BUILD-MONITOR.env</propertiesFile>
              <failTriggerOnMissing>false</failTriggerOnMissing>
              <textParamValueOnNewLine>false</textParamValueOnNewLine>
              <useMatrixChild>false</useMatrixChild>
              <onlyExactRuns>false</onlyExactRuns>
            </hudson.plugins.parameterizedtrigger.FileBuildParameters>
          </configs>
          <projects>BUILD-MONITOR</projects>
          <condition>ALWAYS</condition>
          <triggerWithNoParameters>false</triggerWithNoParameters>
          <triggerFromChildProjects>false</triggerFromChildProjects>
        </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
        <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
          <configs>
            <hudson.plugins.parameterizedtrigger.FileBuildParameters>
              <propertiesFile>DASHBOARD_UPDATE_image_started.env</propertiesFile>
              <failTriggerOnMissing>false</failTriggerOnMissing>
              <textParamValueOnNewLine>false</textParamValueOnNewLine>
              <useMatrixChild>false</useMatrixChild>
              <onlyExactRuns>false</onlyExactRuns>
            </hudson.plugins.parameterizedtrigger.FileBuildParameters>
          </configs>
          <projects>BUILD-MONITOR-GBS</projects>
          <condition>ALWAYS</condition>
          <triggerWithNoParameters>false</triggerWithNoParameters>
          <triggerFromChildProjects>false</triggerFromChildProjects>
        </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
        <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
          <configs>
            <hudson.plugins.parameterizedtrigger.FileBuildParameters>
              <propertiesFile>DASHBOARD_UPDATE_image_finished.env</propertiesFile>
              <failTriggerOnMissing>false</failTriggerOnMissing>
              <textParamValueOnNewLine>false</textParamValueOnNewLine>
              <useMatrixChild>false</useMatrixChild>
              <onlyExactRuns>false</onlyExactRuns>
            </hudson.plugins.parameterizedtrigger.FileBuildParameters>
          </configs>
          <projects>BUILD-MONITOR-GBS</projects>
          <condition>ALWAYS</condition>
          <triggerWithNoParameters>false</triggerWithNoParameters>
          <triggerFromChildProjects>false</triggerFromChildProjects>
        </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
      </configs>
    </hudson.plugins.parameterizedtrigger.BuildTrigger>
    <org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder plugin="groovy-postbuild@2.4">
      <script plugin="script-security@1.43">
        <script>
def now = new Date();
def bm_start_datetime = now.format(&quot;yyyy-MM-dd HH:mm:ss.SSS&quot;, TimeZone.getTimeZone(&apos;UTC&apos;));

def timeout = manager.getLogMatcher(&apos;Build timed out .*&apos;);
def aborted = manager.getLogMatcher(&apos;Build was aborted.*&apos;);

def project =  &quot;&quot;;
def kickstart =  &quot;&quot;;
def name =  &quot;&quot;;
def buildid =  &quot;&quot;;
def repo =  &quot;&quot;;
def images_path =  &quot;&quot;;
def download_num=  &quot;&quot;;
def url_pub_base=  &quot;&quot;;
def repo_path=  &quot;&quot;;
def image_xml = &quot;&quot;;
def status = &apos;failed&apos;;
def bm_stage = &apos;Image&apos;;
def bm_img_size = 0;

if (timeout?.matches() &amp;&amp; aborted?.matches()) {
  def build = Thread.currentThread().executable
  def fileName = &quot;BUILD-MONITOR.env&quot;;

  if(manager.build.workspace.isRemote()) {
    channel = manager.build.workspace.channel;
    file = new hudson.FilePath(channel, manager.build.workspace.toString() + &quot;/&quot; + fileName)
  }
  else {
    File file = new File(build.workspace.toString() + fileName)
  }

  //File file = new File(build.workspace.toString() + &quot;/BUILD-MONITOR.env&quot;)

  manager.addShortText(&apos;TimeOut&apos;);
  project = manager.getLogMatcher(&apos;    &quot;project&quot;: &quot;(.*)&quot;.*&apos;).group(1);
  kickstart = manager.getLogMatcher(&apos;    &quot;kickstart&quot;: &quot;(.*)&quot;.*&apos;).group(1);
  name = manager.getLogMatcher(&apos;    &quot;name&quot;: &quot;(.*)&quot;.*&apos;).group(1);
  buildid = manager.getLogMatcher(&apos;    &quot;buildid&quot;: &quot;(.*)&quot;.*&apos;).group(1);
  repo = manager.getLogMatcher(&apos;    &quot;repo&quot;: &quot;(.*)&quot;.*&apos;).group(1);
  images_path = manager.getLogMatcher(&apos;    &quot;images_path&quot;: &quot;(.*)&quot;.*&apos;).group(1);
  download_num= manager.getLogMatcher(&apos;    &quot;download_num&quot;: (.*),.*&apos;).group(1);
  url_pub_base= manager.getLogMatcher(&apos;    &quot;url_pub_base&quot;: &quot;(.*)&quot;.*&apos;).group(1);
  repo_path= manager.getLogMatcher(&apos;    &quot;repo_path&quot;: &quot;(.*)&quot;.*&apos;).group(1);
  image_xml = &quot;&quot;;
  status = &apos;success&apos;;

/*
  // Cannot use Map type due to representation differs between groovy and python.
  def Map fields = [
    &quot;status&quot;: status,
    &quot;project&quot;: project,
    &quot;kickstart&quot;: kickstart,
    &quot;name&quot;: name,
    &quot;buildid&quot;: buildid,
    &quot;repo&quot;: repo,
    &quot;url&quot;: url_pub_base + &quot;/&quot; + repo_path + &quot;/&quot; + images_path,
    &quot;images_path&quot;: images_path,
    &quot;download_num&quot;: download_num,
    &quot;image_xml&quot;: image_xml,
    &quot;url_pub_base&quot;: url_pub_base,
    &quot;repo_path&quot;: repo_path
  ];
  def Map parameter = [
    &quot;bm_stage&quot;: &quot;Image&quot;,
    &quot;status&quot;: status,
    &quot;bm_img_size&quot;: 0,
    &quot;bm_start_datetime&quot;: &quot;2017&quot;,
    &quot;bm_end_datetime&quot;: &quot;2017&quot;,
    &quot;build_id&quot;: buildid,
    &quot;fields&quot;: fields
  ];

  String str_p = parameter.inspect();
  String encoded = str_p.bytes.encodeBase64().toString();
  file.write(&quot;TRIGGER_INFO=&quot;);
  file.append(encoded);
*/

  now = new Date();
  def bm_end_datetime = now.format(&quot;yyyy-MM-dd HH:mm:ss.SSS&quot;, TimeZone.getTimeZone(&apos;UTC&apos;));

  // Instead print all the data as string.
  def p_str = &apos;{&apos;;
  p_str += &apos;&quot;status&quot;: &quot;&apos; + status + &apos;&quot;,&apos;;
  p_str += &apos;&quot;bm_start_datetime&quot;: &quot;&apos; + bm_start_datetime + &apos;&quot;,&apos;;
  p_str += &apos;&quot;bm_end_datetime&quot;: &quot;&apos; + bm_end_datetime + &apos;&quot;,&apos;;
  p_str += &apos;&quot;bm_stage&quot;: &quot;&apos; + bm_stage + &apos;&quot;,&apos;;
  p_str += &apos;&quot;bm_img_size&quot;: &quot;&apos; + bm_img_size + &apos;&quot;,&apos;;
  p_str += &apos;&quot;build_id&quot;: &quot;&apos; + buildid + &apos;&quot;,&apos;;
  p_str += &apos;&quot;fields&quot;:{&apos;;
  p_str += &apos;&quot;status&quot;: &quot;&apos; + status + &apos;&quot;,&apos;;
  p_str += &apos;&quot;project&quot;: &quot;&apos; + project + &apos;&quot;,&apos;;
  p_str += &apos;&quot;kickstart&quot;: &quot;&apos; + kickstart + &apos;&quot;,&apos;;
  p_str += &apos;&quot;name&quot;: &quot;&apos; + name + &apos;&quot;,&apos;;
  p_str += &apos;&quot;buildid&quot;: &quot;&apos; + buildid + &apos;&quot;,&apos;;
  p_str += &apos;&quot;repo&quot;: &quot;&apos; + repo + &apos;&quot;,&apos;;
  p_str += &apos;&quot;url&quot;: &quot;&apos; + url_pub_base + &apos;/&apos; + repo_path + &apos;/&apos; + images_path + &apos;&quot;,&apos;;
  p_str += &apos;&quot;images_path&quot;: &quot;&apos; + images_path + &apos;&quot;,&apos;;
  p_str += &apos;&quot;download_num&quot;: &apos; + download_num + &apos;,&apos;;
  p_str += &apos;&quot;image_xml&quot;: &quot;&apos; + image_xml + &apos;&quot;,&apos;;
  p_str += &apos;&quot;url_pub_base&quot;: &quot;&apos; + url_pub_base + &apos;&quot;,&apos;;
  p_str += &apos;&quot;repo_path&quot;: &quot;&apos; + repo_path + &apos;&quot;&apos;;
  p_str += &apos;}&apos;;
  p_str += &apos;}&apos;;

  String encoded = p_str.bytes.encodeBase64().toString();
  file.write(&quot;TRIGGER_INFO=&quot; + encoded, null);

} else {
  manager.addShortText(&apos;OK&apos;);
}

</script>
        <sandbox>false</sandbox>
      </script>
      <behavior>0</behavior>
      <runForMatrixParent>false</runForMatrixParent>
    </org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder>
  </publishers>
  <buildWrappers>
    <hudson.plugins.ws__cleanup.PreBuildCleanup plugin="ws-cleanup@0.34">
      <deleteDirs>false</deleteDirs>
      <cleanupParameter></cleanupParameter>
      <externalDelete></externalDelete>
    </hudson.plugins.ws__cleanup.PreBuildCleanup>
    <hudson.plugins.build__timeout.BuildTimeoutWrapper plugin="build-timeout@1.19">
      <strategy class="hudson.plugins.build_timeout.impl.AbsoluteTimeOutStrategy">
        <timeoutMinutes>60</timeoutMinutes>
      </strategy>
      <operationList>
        <hudson.plugins.build__timeout.operations.FailOperation/>
      </operationList>
    </hudson.plugins.build__timeout.BuildTimeoutWrapper>
    <hudson.plugins.timestamper.TimestamperBuildWrapper plugin="timestamper@1.8.9"/>
    <com.michelin.cio.hudson.plugins.copytoslave.CopyToSlaveBuildWrapper plugin="copy-to-slave@1.4.4">
      <includes>configuration, jenkins-scripts/job_gbsfullbuild_image_creator.py, jenkins-scripts/common/*</includes>
      <excludes></excludes>
      <flatten>false</flatten>
      <includeAntExcludes>false</includeAntExcludes>
      <hudsonHomeRelative>false</hudsonHomeRelative>
      <relativeTo>userContent</relativeTo>
    </com.michelin.cio.hudson.plugins.copytoslave.CopyToSlaveBuildWrapper>
    <EnvInjectBuildWrapper plugin="envinject@2.1.5">
      <info>
        <propertiesFilePath>${WORKSPACE}/configuration</propertiesFilePath>
        <secureGroovyScript plugin="script-security@1.43">
          <script></script>
          <sandbox>false</sandbox>
        </secureGroovyScript>
        <loadFilesFromMaster>false</loadFilesFromMaster>
      </info>
    </EnvInjectBuildWrapper>
  </buildWrappers>
</project>