<?xml version="1.0" encoding="UTF-8"?><project>
  <actions/>
  <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
  <keepDependencies>false</keepDependencies>
  <disabled>false</disabled>
  <displayName>PMWG Android on HiKey960</displayName>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <concurrentBuild>false</concurrentBuild>
  <assignedNode>docker-xenial-aosp</assignedNode>
  <canRoam>false</canRoam>
  <properties>
    <hudson.security.AuthorizationMatrixProperty>
      <permission>hudson.model.Item.Read:anonymous</permission>
      <permission>hudson.model.Item.ExtendedRead:anonymous</permission>
      <permission>hudson.model.Item.Workspace:anonymous</permission>
      <permission>hudson.model.Item.Read:everyone-flat</permission>
      <permission>hudson.model.Item.ExtendedRead:everyone-flat</permission>
      <permission>hudson.model.Item.Build:everyone-flat</permission>
      <permission>hudson.model.Item.Cancel:everyone-flat</permission>
    </hudson.security.AuthorizationMatrixProperty>
    <jenkins.model.BuildDiscarderProperty>
      <strategy class="hudson.tasks.LogRotator">
        <daysToKeep>60</daysToKeep>
        <numToKeep>60</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
      </strategy>
    </jenkins.model.BuildDiscarderProperty>
    <hudson.model.ParametersDefinitionProperty>
      <parameterDefinitions>
        <hudson.model.StringParameterDefinition>
          <name>KERNEL_BRANCH</name>
          <description/>
          <defaultValue>android-hikey-linaro-4.9-pmwg</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>KERNEL_DESCRIBE</name>
          <description/>
          <defaultValue/>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>SRCREV_kernel</name>
          <description/>
          <defaultValue/>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>REFERENCE_BUILD_URL</name>
          <description/>
          <defaultValue>https://snapshots.linaro.org/96boards/hikey960/linaro/aosp-master/626/</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>PUB_DEST</name>
          <description/>
          <defaultValue>android/pmwg/${JOB_NAME}/${BUILD_NUMBER}</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>DEFCONFIG</name>
          <description/>
          <defaultValue>hikey960_defconfig</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>DEVICE_TYPE</name>
          <description/>
          <defaultValue>hi960-hikey</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>PUB_DEST</name>
          <description/>
          <defaultValue>android/pmwg/${JOB_NAME}/${BUILD_NUMBER}</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>LAVA_SERVER</name>
          <description/>
          <defaultValue>https://pmwg.validation.linaro.org/RPC2/</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>QA_SERVER</name>
          <description/>
          <defaultValue>https://qa-reports.linaro.org</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>QA_SERVER_PROJECT</name>
          <description/>
          <defaultValue>power</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>QA_SERVER_TEAM</name>
          <description/>
          <defaultValue>pmwg</defaultValue>
        </hudson.model.StringParameterDefinition>
      </parameterDefinitions>
    </hudson.model.ParametersDefinitionProperty>
  </properties>
  <scm class="hudson.plugins.git.GitSCM">
    <configVersion>2</configVersion>
    <userRemoteConfigs>
      <hudson.plugins.git.UserRemoteConfig>
        <name>origin</name>
        <refspec>+refs/heads/${KERNEL_BRANCH}:refs/remotes/origin/${KERNEL_BRANCH}</refspec>
        <url>https://git.linaro.org/power/android.git</url>
      </hudson.plugins.git.UserRemoteConfig>
    </userRemoteConfigs>
    <branches>
      <hudson.plugins.git.BranchSpec>
        <name>origin/${KERNEL_BRANCH}</name>
      </hudson.plugins.git.BranchSpec>
    </branches>
    <disableSubmodules>false</disableSubmodules>
    <recursiveSubmodules>false</recursiveSubmodules>
    <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
    <remotePoll>false</remotePoll>
    <gitTool>Default</gitTool>
    <submoduleCfg class="list"/>
    <reference/>
    <gitConfigName/>
    <gitConfigEmail/>
    <extensions>
      <hudson.plugins.git.extensions.impl.CloneOption>
        <shallow>true</shallow>
        <depth>1</depth>
      </hudson.plugins.git.extensions.impl.CloneOption>
    </extensions>
  </scm>
  <builders>
    <hudson.tasks.Shell>
      <command>#!/bin/bash

set -ex

git clone --depth=1 https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
git clone --depth=1 https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86
export PATH=${PWD}/aarch64-linux-android-4.9/bin/:${PWD}/linux-x86/clang-r346389c/bin/:${PATH}

if ! sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 update; then
  echo &quot;INFO: apt update error - try again in a moment&quot;
  sleep 15
  sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 update || true
fi
pkg_list=&quot;python-pip openssl libssl-dev&quot;
if ! sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 install -y ${pkg_list}; then
  echo &quot;INFO: apt install error - try again in a moment&quot;
  sleep 15
  sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 install -y ${pkg_list}
fi

export CLANG_TRIPLE=aarch64-linux-gnu-
export CROSS_COMPILE=aarch64-linux-android-
make ARCH=arm64 ${DEFCONFIG}
make ARCH=arm64  CC=clang HOSTCC=clang -j$(nproc) -s Image.gz-dtb

wget -q https://android-git.linaro.org/platform/system/core.git/plain/mkbootimg/mkbootimg.py -O mkbootimg
wget -q ${REFERENCE_BUILD_URL}/ramdisk.img -O ramdisk.img

mkdir -p out
case &quot;${DEFCONFIG}&quot; in
  hikey_defconfig)
    python mkbootimg \
      --kernel ${PWD}/arch/arm64/boot/Image.gz-dtb \
      --cmdline &quot;console=ttyAMA3,115200 androidboot.console=ttyAMA3,115200 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab&quot; \
      --os_version O \
      --os_patch_level 2016-11-05 \
      --ramdisk ramdisk.img \
      --output out/boot.img
    ;;
  hikey960_defconfig)
    python mkbootimg \
      --kernel ${PWD}/arch/arm64/boot/Image.gz-dtb \
      --cmdline &quot;androidboot.hardware=hikey960 firmware_class.path=/vendor/firmware buildvariant=userdebug overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab&quot; \
      --base 0x0 --tags_offset 0x07a00000 --kernel_offset 0x00080000 \
      --ramdisk_offset 0x07c00000 \
      --os_version P \
      --os_patch_level 2016-11-05 \
      --ramdisk ramdisk.img \
      --output out/boot.img
    ;;
esac
xz out/boot.img
</command>
    </hudson.tasks.Shell>
    <linaro.pubapi.LinaroPubAPIKey>
      <credentialsId>snapshots.linaro.org</credentialsId>
    </linaro.pubapi.LinaroPubAPIKey>
    <hudson.tasks.Shell>
      <command>#!/bin/bash

# Required for Mali binaries
wget -q https://git.linaro.org/ci/job/configs.git/blob_plain/HEAD:/android-lcr/hikey/build-info/aosp-master-template.txt -O out/BUILD-INFO.txt

# Publish
test -d ${HOME}/bin || mkdir ${HOME}/bin
wget -q https://git.linaro.org/ci/publishing-api.git/blob_plain/HEAD:/linaro-cp.py -O ${HOME}/bin/linaro-cp.py
time python3 ${HOME}/bin/linaro-cp.py \
  --server ${PUBLISH_SERVER} \
  --build-info out/BUILD-INFO.txt \
  --link-latest \
  out/ ${PUB_DEST}
</command>
    </hudson.tasks.Shell>
    <hudson.tasks.Shell>
      <command>#!/bin/bash

set -ex

rm -rf configs
git clone --depth 1 http://git.linaro.org/ci/job/configs.git

# Install jinja2-cli and ruamel.yaml==0.16.13
if ! sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 update; then
  echo &quot;INFO: apt update error - try again in a moment&quot;
  sleep 15
  sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 update || true
fi
pkg_list=&quot;virtualenv python-pip&quot;
if ! sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 install -y ${pkg_list}; then
  echo &quot;INFO: apt install error - try again in a moment&quot;
  sleep 15
  sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 install -y ${pkg_list}
fi
pip install --user --force-reinstall jinja2-cli ruamel.yaml==0.16.13

[ -z &quot;${DEVICE_TYPE}&quot; ] || \
python configs/openembedded-lkft/submit_for_testing.py \
  --device-type ${DEVICE_TYPE} \
  --build-number ${BUILD_NUMBER} \
  --lava-server ${LAVA_SERVER} \
  --qa-server ${QA_SERVER} \
  --qa-server-team ${QA_SERVER_TEAM} \
  --qa-server-project ${QA_SERVER_PROJECT} \
  --git-commit ${GIT_COMMIT:0:12} \
  --template-path configs/android-hikey-linaro-4.9-pmwg/lava-job-definitions \
  --template-names vellamo-template.yaml multimedia-template.yaml
</command>
    </hudson.tasks.Shell>
  </builders>
  <publishers>
    <hudson.plugins.logparser.LogParserPublisher plugin="log-parser">
      <unstableOnWarning>false</unstableOnWarning>
      <failBuildOnError>false</failBuildOnError>
      <showGraphs>true</showGraphs>
      <useProjectRule>true</useProjectRule>
      <projectRulePath>/var/jenkins_home/userContent/android.parse</projectRulePath>
    </hudson.plugins.logparser.LogParserPublisher>
    <hudson.tasks.Fingerprinter>
      <targets>build/fingerprints/*</targets>
      <recordBuildArtifacts>false</recordBuildArtifacts>
    </hudson.tasks.Fingerprinter>
    <org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder>
      <behavior>0</behavior>
      <runForMatrixParent>false</runForMatrixParent>
      <script>
        <script>import hudson.model.*

if (manager.build.result == hudson.model.Result.SUCCESS) {
  def qa_server = manager.build.buildVariables.get('QA_SERVER')
  def desc = manager.build.getDescription()
  if (desc == null) {
    desc = &quot;&quot;
  }
  pattern = ~&quot;${qa_server}/testjob/(\\d+)&quot;
  manager.build.logFile.eachLine { line -&gt;
    matcher = pattern.matcher(line)
    if(matcher.matches()) {
      def url = matcher.group(0)
      def testjob_id = matcher.group(1)
      desc += &quot;&amp;nbsp;&lt;a href='${url}'&gt;QA Reports: ${testjob_id}&lt;/a&gt;&lt;br/&gt;&quot;
    }
  }
  manager.build.setDescription(desc)
}

// Parse log file to find warnings and errors
def logFile = manager.build.logFile.text
def warnings = logFile =~ /(?ms)(^.*? warning: .*?$)/
def errors = logFile =~ /(?ms)(^.*? error: .*?$)/
def warningsCount = warnings.count
def errorsCount = errors.count

// Update parameters to include warnings and errors values
def action = manager.build.getAction(hudson.model.ParametersAction.class)
def parameters = [
  new StringParameterValue(&quot;WARNINGS&quot;, &quot;${warningsCount}&quot;),
  new StringParameterValue(&quot;ERRORS&quot;, &quot;${errorsCount}&quot;)
]
updatedAction = action.createUpdated(parameters)
manager.build.replaceAction(updatedAction)
</script>
        <sandbox>false</sandbox>
      </script>
    </org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder>
    <hudson.plugins.emailext.ExtendedEmailPublisher>
      <recipientList>private-pmwg@lists.linaro.org, vishal.bhoj@linaro.org, fathi.boudra@linaro.org</recipientList>
      <configuredTriggers>
        <hudson.plugins.emailext.plugins.trigger.AlwaysTrigger>
          <email>
            <recipientList/>
            <subject>$PROJECT_DEFAULT_SUBJECT</subject>
            <body>$PROJECT_DEFAULT_CONTENT</body>
            <sendToRequester>false</sendToRequester>
            <sendToDevelopers>false</sendToDevelopers>
            <includeCulprits>false</includeCulprits>
            <sendToRecipientList>true</sendToRecipientList>
          </email>
        </hudson.plugins.emailext.plugins.trigger.AlwaysTrigger>
        <hudson.plugins.emailext.plugins.trigger.FailureTrigger>
          <email>
            <recipientList/>
            <subject>$PROJECT_DEFAULT_SUBJECT</subject>
            <body>$PROJECT_DEFAULT_CONTENT</body>
            <sendToRequester>false</sendToRequester>
            <sendToDevelopers>false</sendToDevelopers>
            <includeCulprits>false</includeCulprits>
            <sendToRecipientList>true</sendToRecipientList>
          </email>
        </hudson.plugins.emailext.plugins.trigger.FailureTrigger>
      </configuredTriggers>
      <contentType>text/plain</contentType>
      <defaultSubject>[Jenkins] Build HiKey960 (${WARNINGS}/${ERRORS}): ${GIT_BRANCH} ${GIT_REVISION,length=12}</defaultSubject>
      <defaultContent>Project: ${PROJECT_NAME}
Build number: ${BUILD_NUMBER}
Build status: ${BUILD_STATUS}
Build URL: ${BUILD_URL}
Build location: ${PUBLISH_SERVER}${PUB_DEST}
Console output: ${BUILD_URL}consoleText
Parsed warnings/errors: ${BUILD_URL}parsed_console
Git branch: ${GIT_BRANCH}
Git commit: ${GIT_COMMIT}

${GIT_URL}/commit/?h=${KERNEL_BRANCH}&amp;id=${GIT_COMMIT}

Errors:
${BUILD_LOG_REGEX, regex=&quot;^.*? error: .*?$&quot;, linesBefore=0, linesAfter=2, showTruncatedLines=false}

Warnings:
${BUILD_LOG_REGEX, regex=&quot;^.*? warning: .*?$&quot;, linesBefore=0, linesAfter=2, showTruncatedLines=false}
</defaultContent>
      <attachmentsPattern/>
      <presendScript/>
      <postsendScript/>
      <attachBuildLog>true</attachBuildLog>
      <compressBuildLog>false</compressBuildLog>
      <saveOutput>false</saveOutput>
      <disabled>false</disabled>
      <replyTo>$DEFAULT_REPLYTO</replyTo>
    </hudson.plugins.emailext.ExtendedEmailPublisher>
  </publishers>
  <buildWrappers>
    <hudson.plugins.timestamper.TimestamperBuildWrapper/>
    <org.jenkinsci.plugins.buildnamesetter.BuildNameSetter>
      <template>#${BUILD_NUMBER}-${GIT_REVISION,length=12}</template>
    </org.jenkinsci.plugins.buildnamesetter.BuildNameSetter>
    <hudson.plugins.build__timeout.BuildTimeoutWrapper>
      <strategy class="hudson.plugins.build_timeout.impl.AbsoluteTimeOutStrategy">
        <timeoutMinutes>500</timeoutMinutes>
      </strategy>
      <operationList>
        <hudson.plugins.build__timeout.operations.AbortOperation/>
      </operationList>
    </hudson.plugins.build__timeout.BuildTimeoutWrapper>
    <org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper>
      <bindings>
        <org.jenkinsci.plugins.credentialsbinding.impl.StringBinding>
          <variable>QA_REPORTS_TOKEN</variable>
          <credentialsId>QA_REPORTS_TOKEN</credentialsId>
        </org.jenkinsci.plugins.credentialsbinding.impl.StringBinding>
      </bindings>
    </org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper>
  </buildWrappers>
</project>