agent

get information

get all

get all agents including Jenkins master:

  • or

Computer and Node

example for Computer Object

  • get description

  • get all info

    • result

example for Node Object

  • result

setup hold off launch via: agent.holdOffLaunchUntilSave = true

  • node -> computer

  • or get log

get projects tied to agent

[!NOTE|label:reference:]

  • result get project(s) via agent

  • or

  • get running job from label

    [!TIP] solution:

    • hudson.model.Executor -> hudson.model.queue.WorkUnit -> org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask

    • hudson.model.Executor -> hudson.model.queue.WorkUnit -> hudson.model.queue.WorkUnitContext -> org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask

    might helps: Label Linked Jobs

get number of executor of agents

or

or

get agent credentialsId

[!NOTE|label:references:]

  • or simple output

  • or

  • or

get agent environment variable

get agent labels

  • function

    • or

cloud agents

check how many cloud agent running

KubernetesComputer

[!NOTE] references:

  • result

executor

reference:

[!NOTE|label:getParentExecutable]

basic usage

  • result

features

  • result

stop all running builds via WorkflowRun

[!NOTE]

  • using WorkflowRun.finish might cause issue : https://stackoverflow.com/q/75651552/2940319

force interrupt executors

[!NOTE|label:basic concept] Computer -> Executor -> ExecutorStepExecution$PlaceholderTask$PlaceholderExecutable -> WorkflowRun

to WorkUnit and SubTask ( ExecutorStepExecution.PlaceholderTask )

  • result

to Computer

  • result

[!NOTE|label:references:]

useful libs:

  • import jenkins.model.*

  • import hudson.slaves.*

  • import hudson.slaves.NodePropertyDescriptor

  • import hudson.plugins.sshslaves.*

  • import hudson.plugins.sshslaves.verifiers.*

  • import hudson.model.*

  • import hudson.model.Node

  • import hudson.model.Queue

  • import hudson.model.queue.CauseOfBlockage

  • import hudson.slaves.EnvironmentVariablesNodeProperty.Entry

  • import java.util.ArrayList

  • import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.nodes.JobRestrictionProperty

  • import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.Messages

  • import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.JobRestriction

  • import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.JobRestrictionBlockageCause

  • import hudson.Extension

  • import hudson.slaves.NodeProperty

  • import org.kohsuke.stapler.DataBoundConstructor

  • SSH host verification strategy:

update agent label

[!NOTE|label:references:]

update agent credentialsId

[!NOTE|label:references:]

  • or simply

  • by Jenkins.instance.addNode

universal agent update

disconnect agent

  • legacy version

temporarily offline agent

[!NOTE|label:references:]

  • legacy version

restart agent

[!NOTE|label:references:]

delete agent

references:

for jenkins master

execute gc

display http sessions

display a simple threads dump

display deadlocked threads

display some memory data

display some jvm data

display heap histogram (object instances per class)

take a heap dump

display some MBean attribute value

send alerts

[!TIP|label:references:]

  • suppose that you want to check:

    • every 15 minutes on the Jenkins master,

    • if the system load average is above 50

    • if the active HTTP threads count is above 100

    • if there are deadlocked threads

    • if there are less than 10 Gb free disk space left:

  • by:

    • create a freestyle job in jenkins by clicking "New Item".

    • check "build periodically" and write a schedule, "*/15 * * * *" for example.

    • add a build step "execute system groovy script" and write a script

- or any script with monitoring values in this page - add a post-build action "E-mail Notification" and write your email in "Recipients". - you can also configure "Discard old builds" and write a description. - save. - click "Build now" to test it.

for jenkins agents

display jvm data, memory data, deadlocked threads by node

display some mbean attributes values by node

Last updated

Was this helpful?