title: How can I use vSphere Cloud Plugin inside Jenkins pipeline code?
body: <p>I have a setup at work where the vSphere host are manually restarted before execution of a specific jenkins job, as a noob in the office I automated this process by adding a extra build step to restart vm's with the help of <a href="https://wiki.jenkins-ci.org/display/JENKINS/vSphere+Cloud+Plugin" rel="nofollow noreferrer">https://wiki.jenkins-ci.org/display/JENKINS/vSphere+Cloud+Plugin</a>! (vSphere cloud plugin).
  I would like to now integrate this as a pipeline code, please advise.
  I have already checked that this plugin is Pipeline compatible.</p>
  
  <p>I currently trigger the vSphere host restart in pipeline by making it to remotely trigger a job configured with vSphere cloud plugin.</p>
  
  <pre><code>pipeline {
      agent any
      stages {
          stage('Restarting vSphere') {
              steps {
              script {
                  sh "curl -v 'http://someserver.com/job/Vivin/job/executor_configurator/buildWithParameters?Host=build-114&amp;token=bonkers'"                
              }
              }
          }
          stage('Setting Executors') {
              steps {
                  script {
                  def jenkins = Jenkins.getInstance()
                  jenkins.getNodes().each { 
                  if (it.displayName == 'brewery-133') {
                  echo 'brewery-133'
                  it.setNumExecutors(8)
                  }                    
                  }
                  }
              }
          }
  
      }
  }
  </code></pre>
  
  <p>I would like to integrate the vSphere cloud plugin directly in the Pipeline code itself, please help me to integrate.</p>
  
  <pre><code>pipeline {
      agent any
      stages {
          stage('Restarting vSphere') {
              steps {
  
              vSphere cloud plugin code that is requested
  
              }
              }
          }
          stage('Setting Executors') {
              steps {
                  script {
                  def jenkins = Jenkins.getInstance()
                  jenkins.getNodes().each { 
                  if (it.displayName == 'brewery-133') {
                  echo 'brewery-133'
                  it.setNumExecutors(8)
                  }                    
                  }
                  }
              }
          }
  
      }
  }
  </code></pre>