<?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>TCWG CCC Cleanup stale containers</displayName>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <concurrentBuild>true</concurrentBuild>
  <customWorkspace>workspace/tcwg-cleanup-stale-containers_$EXECUTOR_NUMBER/$NODE_NAME</customWorkspace>
  <canRoam>true</canRoam>
  <properties>
    <hudson.security.AuthorizationMatrixProperty>
      <permission>hudson.model.Item.Read:anonymous</permission>
      <permission>hudson.model.Item.ExtendedRead:anonymous</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>30</daysToKeep>
        <numToKeep>100</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
      </strategy>
    </jenkins.model.BuildDiscarderProperty>
    <hudson.plugins.throttleconcurrents.ThrottleJobProperty>
      <maxConcurrentPerNode>1</maxConcurrentPerNode>
      <maxConcurrentTotal>0</maxConcurrentTotal>
      <throttleEnabled>true</throttleEnabled>
      <throttleOption>project</throttleOption>
      <configVersion>1</configVersion>
      <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
      <matrixOptions>
        <throttleMatrixBuilds>true</throttleMatrixBuilds>
        <throttleMatrixConfigurations>false</throttleMatrixConfigurations>
      </matrixOptions>
      <paramsToUseForLimit/>
    </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
    <hudson.model.ParametersDefinitionProperty>
      <parameterDefinitions>
        <org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
          <name>slave_list</name>
          <description>Machines to run on</description>
          <defaultValue>tcwg</defaultValue>
          <allNodesMatchingLabel>true</allNodesMatchingLabel>
          <triggerIfResult>allCases</triggerIfResult>
          <nodeEligibility class="org.jvnet.jenkins.plugins.nodelabelparameter.node.AllNodeEligibility"/>
        </org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>cleanup_running_hours</name>
          <description>Delete containers that are more then "hours" old.  Use "0" to disable time check.  Use negative values for dry-run.</description>
          <defaultValue>48</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>cleanup_stopped_hours</name>
          <description>Delete containers that are more then "hours" old.  Use "0" to disable the cleanup.  Use negative values for dry-run.</description>
          <defaultValue>240</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>cleanup_ssh_agent_hours</name>
          <description>Kill ssh-agent processes that are more then "hours" old.  Use "0" to disable time check.</description>
          <defaultValue>48</defaultValue>
        </hudson.model.StringParameterDefinition>
        <hudson.model.BooleanParameterDefinition>
          <name>cleanup_volumes</name>
          <description>Whether to cleanup dangling volumes</description>
          <defaultValue>true</defaultValue>
        </hudson.model.BooleanParameterDefinition>
        <hudson.model.BooleanParameterDefinition>
          <name>cleanup_images</name>
          <description>Whether to cleanup images</description>
          <defaultValue>true</defaultValue>
        </hudson.model.BooleanParameterDefinition>
        <hudson.model.BooleanParameterDefinition>
          <name>verbose</name>
          <description>Whether to be verbose</description>
          <defaultValue>false</defaultValue>
        </hudson.model.BooleanParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>scripts_branch</name>
          <description>Scripts revision to use</description>
          <defaultValue>refs/heads/master</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/*:refs/remotes/origin/* +refs/changes/*:refs/changes/*</refspec>
        <url>https://gitlab.com/LinaroLtd/tcwg/jenkins-scripts.git</url>
      </hudson.plugins.git.UserRemoteConfig>
    </userRemoteConfigs>
    <branches>
      <hudson.plugins.git.BranchSpec>
        <name>${scripts_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>
      <hudson.plugins.git.extensions.impl.WipeWorkspace/>
    </extensions>
  </scm>
  <triggers class="vector">
    <hudson.triggers.TimerTrigger>
      <spec>@daily</spec>
    </hudson.triggers.TimerTrigger>
  </triggers>
  <builders>
    <hudson.tasks.Shell>
      <command>#!/bin/bash
set -ex
cat &lt;&lt; EOF &gt; mail-body.txt
Cleaning stale containers on $NODE_NAME.
Please check console output at $BUILD_URL to view the results
EOF
case " $NODE_LABELS " in
  *" tcwg-secondary-node "*)
    # Only cleanup ssh-agent processes for secondary nodes.
    ./tcwg-cleanup-stale-containers.sh --cleanup-running-hours 0 --cleanup-stopped-hours 0 --cleanup-ssh-agent-hours $cleanup_ssh_agent_hours --cleanup-volumes false --cleanup-images false --verbose $verbose || true
    exit 0
    ;;
esac

$WORKSPACE/tcwg-cleanup-stale-containers.sh --cleanup-running-hours $cleanup_running_hours --cleanup-stopped-hours $cleanup_stopped_hours --cleanup-ssh-agent-hours $cleanup_ssh_agent_hours --cleanup-volumes $cleanup_volumes --cleanup-images $cleanup_images --verbose $verbose
</command>
    </hudson.tasks.Shell>
  </builders>
  <publishers>
    <hudson.plugins.emailext.ExtendedEmailPublisher>
      <recipientList>tcwg-validation@linaro.org</recipientList>
      <configuredTriggers>
        <hudson.plugins.emailext.plugins.trigger.AbortedTrigger>
          <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.AbortedTrigger>
        <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>$DEFAULT_SUBJECT</defaultSubject>
      <defaultContent>${FILE,path="mail-body.txt"}
</defaultContent>
      <attachmentsPattern/>
      <presendScript/>
      <postsendScript/>
      <attachBuildLog>false</attachBuildLog>
      <compressBuildLog>false</compressBuildLog>
      <saveOutput>false</saveOutput>
      <disabled>false</disabled>
      <replyTo>$DEFAULT_REPLYTO</replyTo>
    </hudson.plugins.emailext.ExtendedEmailPublisher>
  </publishers>
  <buildWrappers>
    <hudson.plugins.build__timeout.BuildTimeoutWrapper>
      <strategy class="hudson.plugins.build_timeout.impl.AbsoluteTimeOutStrategy">
        <timeoutMinutes>600</timeoutMinutes>
      </strategy>
      <operationList>
        <hudson.plugins.build__timeout.operations.AbortOperation/>
      </operationList>
    </hudson.plugins.build__timeout.BuildTimeoutWrapper>
    <hudson.plugins.timestamper.TimestamperBuildWrapper/>
    <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
      <user>tcwg-benchmark</user>
      <ignoreMissing>false</ignoreMissing>
    </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
    <org.jenkinsci.plugins.buildnamesetter.BuildNameSetter>
      <template>#${BUILD_NUMBER}-${NODE_NAME}</template>
    </org.jenkinsci.plugins.buildnamesetter.BuildNameSetter>
  </buildWrappers>
</project>