Creating your own 'agent' directive (like docker or dockerfile)


We are using jenkins-inbound agent docker images in a grid computing environment using the Univa Grid Engine - a batch queuing system (Univa Grid Engine - Wikipedia).

The type of myAgent is based on the DumbSlave class with a few extra methods and attributes. provisionAgent runs a script which runs the jenkins/inbound-agent image, and connects it to our master node.

stage('Create node') {
    myAgent = provisionAgent()

stage('Use node') {
    agent { myAgent.getLabel() } // gets label based on job name + build number
    steps {
         stage {
             docker { ... }
             steps { // further steps inside docker container 

stage ('Remove node') {

My question is - can this behaviour be encapsulated in a way that the provisionAgent() and removeAgent() steps are hidden from the user? In other words, I am looking for a way to create an agent directive which creates a node, connects it to master and destroys it once the job is complete. Is that possible or does the jenkins design not allow for this?

Write a plugin that implements Cloud (Jenkins core 2.365 API)

1 Like