<?xml version="1.1" encoding="UTF-8" standalone="no"?><matrix-project plugin="matrix-project@822.824.v14451b_c0fd42">
  <actions/>
  <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
  <displayName>CI Dockerfiles build/publish deployment</displayName>
  <keepDependencies>false</keepDependencies>
  <properties>
    <hudson.plugins.buildblocker.BuildBlockerProperty plugin="build-blocker-plugin@1.7.9">
      <useBuildBlocker>true</useBuildBlocker>
      <blockLevel>NODE</blockLevel>
      <scanQueueFor>DISABLED</scanQueueFor>
      <blockingJobs>ci-docker.*</blockingJobs>
    </hudson.plugins.buildblocker.BuildBlockerProperty>
    <jenkins.model.BuildDiscarderProperty>
      <strategy class="hudson.tasks.LogRotator">
        <daysToKeep>90</daysToKeep>
        <numToKeep>200</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
      </strategy>
    </jenkins.model.BuildDiscarderProperty>
    <org.bstick12.jenkinsci.plugins.leastload.LeastLoadDisabledProperty plugin="leastload@3.0.0">
      <leastLoadDisabled>false</leastLoadDisabled>
    </org.bstick12.jenkinsci.plugins.leastload.LeastLoadDisabledProperty>
    <com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty plugin="naginator@1.436.vb_e769dcb_cdf6">
      <optOut>false</optOut>
    </com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty>
    <com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@330.v645b_7df10e2a_">
      <autoRebuild>false</autoRebuild>
      <rebuildDisabled>false</rebuildDisabled>
    </com.sonyericsson.rebuild.RebuildSettings>
    <hudson.model.ParametersDefinitionProperty>
      <parameterDefinitions>
        <hudson.model.StringParameterDefinition>
          <name>PATCHSET_REVISION</name>
          <description>patchset revision</description>
          <defaultValue>origin/main</defaultValue>
          <trim>false</trim>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>BRANCH</name>
          <description>branch of dockerfiles to rebuild</description>
          <defaultValue>main</defaultValue>
          <trim>false</trim>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>nb_rev</name>
          <description>nb of revision to process</description>
          <defaultValue>1</defaultValue>
          <trim>false</trim>
        </hudson.model.StringParameterDefinition>
      </parameterDefinitions>
    </hudson.model.ParametersDefinitionProperty>
    <hudson.plugins.heavy__job.HeavyJobProperty plugin="heavy-job@1.1">
      <weight>1</weight>
    </hudson.plugins.heavy__job.HeavyJobProperty>
    <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@2.14">
      <maxConcurrentPerNode>0</maxConcurrentPerNode>
      <maxConcurrentTotal>0</maxConcurrentTotal>
      <categories class="java.util.concurrent.CopyOnWriteArrayList"/>
      <throttleEnabled>false</throttleEnabled>
      <throttleOption>project</throttleOption>
      <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
      <matrixOptions>
        <throttleMatrixBuilds>true</throttleMatrixBuilds>
        <throttleMatrixConfigurations>false</throttleMatrixConfigurations>
      </matrixOptions>
      <paramsToUseForLimit/>
    </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
    
  </properties>
  <scm class="hudson.plugins.git.GitSCM" plugin="git@5.2.1">
    <configVersion>2</configVersion>
    <userRemoteConfigs>
      <hudson.plugins.git.UserRemoteConfig>
        <name>origin</name>
        <refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
        <url>https://gitlab.com/LinaroLtd/tcwg/ci/dockerfiles</url>
      </hudson.plugins.git.UserRemoteConfig>
    </userRemoteConfigs>
    <branches>
      <hudson.plugins.git.BranchSpec>
        <name>**</name>
      </hudson.plugins.git.BranchSpec>
    </branches>
    <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
    <submoduleCfg class="empty-list"/>
    <extensions>
      <hudson.plugins.git.extensions.impl.RelativeTargetDirectory>
        <relativeTargetDir>dockerfiles</relativeTargetDir>
      </hudson.plugins.git.extensions.impl.RelativeTargetDirectory>
      <hudson.plugins.git.extensions.impl.CleanBeforeCheckout>
        <deleteUntrackedNestedRepositories>false</deleteUntrackedNestedRepositories>
      </hudson.plugins.git.extensions.impl.CleanBeforeCheckout>
      <hudson.plugins.git.extensions.impl.WipeWorkspace/>
    </extensions>
  </scm>
  <assignedNode>triggers</assignedNode>
  <canRoam>false</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers/>
  <concurrentBuild>false</concurrentBuild>
  <axes>
    <hudson.matrix.LabelAxis>
      <name>label</name>
      <values>
        <string>tcwg-amp-02</string>
        <string>tcwg-x86_64-dev-01</string>
      </values>
    </hudson.matrix.LabelAxis>
  </axes>
  <builders>
    <hudson.tasks.Shell>
      <command>#!/bin/bash -e
curl -L -o ${WORKSPACE}/config.json https://ci.linaro.org/userContent/config.json --fail
</command>
      <configuredLocalRules/>
    </hudson.tasks.Shell>
    <hudson.tasks.Shell>
      <command>#!/bin/bash -e
echo "#${BUILD_NUMBER}-${PATCHSET_REVISION}" &gt; ${WORKSPACE}/version.txt
</command>
      <configuredLocalRules/>
    </hudson.tasks.Shell>
    <org.jenkinsci.plugins.buildnameupdater.BuildNameUpdater plugin="build-name-setter@2.4.1">
      <buildName>version.txt</buildName>
      <macroTemplate>#${BUILD_NUMBER}</macroTemplate>
      <fromFile>true</fromFile>
      <fromMacro>false</fromMacro>
      <macroFirst>false</macroFirst>
    </org.jenkinsci.plugins.buildnameupdater.BuildNameUpdater>
    <hudson.tasks.Shell>
      <command>#!/bin/bash

set -ex

rm -f ${WORKSPACE}/log
cd dockerfiles/

git_commit=$(git rev-parse ${PATCHSET_REVISION})
git_previous_commit=$(git rev-parse ${PATCHSET_REVISION}~${nb_rev})

echo ""
echo "########################################################################"
echo "GIT_COMMIT=${git_commit}"
echo "GIT_PREVIOUS_COMMIT=${git_previous_commit}"
echo "BRANCH=${BRANCH}"
echo "########################################################################"

files=$(git diff --name-only ${git_previous_commit} ${git_commit})
echo Changes in: ${files}
changed_dirs=$(dirname ${files}|sort -u)

update_images=""
for dir in ${changed_dirs}; do
  # Find the closest directory with build.sh.  This is, primarily,
  # to handle changes to tcwg-base/tcwg-build/tcwg-builslave/* directories.
  while [ ! -e ${dir}/build.sh -a ! -e ${dir}/.git ]; do
    dir=$(dirname ${dir})
  done
  # Add this and all dependant images in the update.
  dir_basename=$(basename ${dir})
  case "${dir_basename}" in
    "tcwg-"*)
      # ${dir} is one of generic tcwg-base/* directories.  Add dependent
      # images to the list.
      update_images="${update_images} $(dirname $(find . -path "*-${dir_basename}*/build.sh" | sed -e "s#^\./##g"))"
      ;;
  ".")
      continue
      ;;
    *)
      update_images="${update_images} $(dirname $(find ${dir} -name build.sh))"
      ;;
  esac
done
update_images="$(echo "${update_images}" | tr " " "\n" | sort -u)"

host_arch=$(dpkg-architecture -qDEB_HOST_ARCH)

for image in ${update_images}; do
  (
  cd ${image}
  image_arch=$(basename ${PWD} | cut -f2 -d '-')
  skip="skip"
  if [ x"${BRANCH}" = x"main" ]; then
    # Build only from "main" branch.
    skip="no"
  fi
  case "${skip}:${host_arch}:${image_arch}" in
    "skip:"*)
      echo "Skipping: don't need to build ${image} on branch ${BRANCH}"
      ;;
    "no:amd64:amd64"|"no:amd64:i386"|"no:arm64:arm64"|"no:armhf:armhf"|"no:arm64:armhf")
      echo "=== Start build: ${image} ==="
      ./build.sh || echo "=== FAIL: ${image} ===" &gt;&gt; ${WORKSPACE}/log
      ;;
    *)
      echo "Skipping: can't build for ${image_arch} on ${host_arch}"
      ;;
  esac
  )||echo $image failed &gt;&gt; ${WORKSPACE}/log
done

</command>
      <configuredLocalRules/>
    </hudson.tasks.Shell>
    <hudson.tasks.Shell>
      <command>#!/bin/bash

set -ex

trap cleanup_exit INT TERM EXIT

cleanup_exit()
{
    rm -rf ${HOME}/.docker
    rm -f ${WORKSPACE}/{log,config.json,version.txt}
}

docker_log_in()
{
    mkdir -p ${HOME}/.docker
    sed -e "s|\${DOCKER_AUTH}|${DOCKER_AUTH}|" &lt; ${WORKSPACE}/config.json &gt; ${HOME}/.docker/config.json
    chmod 0600 ${HOME}/.docker/config.json
}

update_images=$(find -type f -name .docker-tag)
docker_log_in
for imagename in ${update_images}; do
  (
    docker_tag=$(cat $imagename)
    if [ x"${BRANCH}" != x"main" ]; then
      new_tag=${docker_tag}-${BRANCH}
      docker tag ${docker_tag} ${new_tag}
      docker_tag=${new_tag}
    fi
    for i in 30 60 120;
    do
        docker push ${docker_tag} &amp;&amp; exit 0 || true
        sleep $i
        docker_log_in
    done
    exit 1
  )||echo $imagename push failed &gt;&gt; ${WORKSPACE}/log
done

if [ -e ${WORKSPACE}/log ]
then
    echo "some images failed:"
    cat ${WORKSPACE}/log
    exit 1
fi
</command>
      <configuredLocalRules/>
    </hudson.tasks.Shell>
  </builders>
  <publishers>
    <hudson.tasks.BuildTrigger>
      <childProjects>ci-dockerslaves-cleanup</childProjects>
      <threshold>
        <name>SUCCESS</name>
        <ordinal>0</ordinal>
        <color>BLUE</color>
        <completeBuild>true</completeBuild>
      </threshold>
    </hudson.tasks.BuildTrigger>
    <hudson.tasks.Mailer plugin="mailer@472.vf7c289a_4b_420">
      <recipients>tcwg-validation@linaro.org</recipients>
      <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
      <sendToIndividuals>false</sendToIndividuals>
    </hudson.tasks.Mailer>
  </publishers>
  <buildWrappers>
    <org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper plugin="credentials-binding@657.v2b_19db_7d6e6d">
      <bindings>
        <org.jenkinsci.plugins.credentialsbinding.impl.StringBinding>
          <credentialsId>JJB_USER</credentialsId>
          <variable>DOCKER_AUTH</variable>
        </org.jenkinsci.plugins.credentialsbinding.impl.StringBinding>
      </bindings>
    </org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper>
    <hudson.plugins.timestamper.TimestamperBuildWrapper plugin="timestamper@1.26"/>
  </buildWrappers>
  <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
    <runSequentially>false</runSequentially>
  </executionStrategy>
</matrix-project>