playbooks/roles/jenkins/files/opt/lifecycle-poller/worker.rb
#------------------------------------------------------------------------------
# 
# FUNCTION: takeAgentTemporarilyOffline
#
# DESCRIPTION: This will take the given agent temporarily off
#
#------------------------------------------------------------------------------
takeAgentTemporarilyOffline
DESCRIPTION: This will take the given agent temporarily off
takeAgentTemporarilyOffline DESCRIPTION : This will take the given agent temporarily off
def takeAgentTemporarilyOffline(agent)
  out=`java -jar #{$jenkins_cli} -s http://localhost:8080 -auth 'admin:#{$conf['masterAdminPassword']}' offline-node #{agent} -m 'scale down' 2>&1`
  if $?.exitstatus == 0
    $log.info "agent #{agent} is marked as offline"
    return true
  else
    if out.include? "ERROR: No such agent"
      $log.info "agent #{agent} could not be marked as offline, it already is deleted: #{out}"
      return true
    else
      $log.error "agent #{agent} could not be marked as offline: #{out}"
      return false
    end
  end
end
def takeAgentTemporarilyOffline ( agent ) out = ` java -jar  #{ $jenkins_cli }  -s http://localhost:8080 -auth 'admin: #{ $conf [ 'masterAdminPassword' ] } ' offline-node  #{ agent }  -m 'scale down' 2>&1 ` if $? . exitstatus == 0 $log . info "agent #{agent} is marked as offline" return true else if out . include? "ERROR: No such agent" $log . info "agent #{agent} could not be marked as offline, it already is deleted: #{out}" return true else $log . error "agent #{agent} could not be marked as offline: #{out}" return false end end end
FUNCTION: takeAgentTemporarilyOffline
DESCRIPTION: This will take the given agent temporarily off
FUNCTION : takeAgentTemporarilyOffline DESCRIPTION : This will take the given agent temporarily off
# sterr is forwarded to sdout to get the information in ruby
agent
<not_specific>