jenkinsjenkins-pipelinejenkins-shared-libraries

Jenkins Shared Library script on Jenkins Agent nodes


I noticed JSL scripts get executed only on Jenkins Master, is it possible to run JSL script on Jenkins Agents?

I have multiple stages in my Pipeline and I wish to run those stages on different Jenkins Agent nodes.

My primary motivation for using JSL is end-to-end Pipeline testability during development with "replay", where I can modify Jenkinsfile as well as scripts from JSL.

This is a snippet of my Pipeline --

pipeline {
   agent { label 'scdc-generic-w10x64' }
   options {
      timestamps()
   }
   stages {
      stage('Log ip') {
        steps {
            script {
               bat "ipconfig -all"   // *** Gets executed on Jenkins Agent ***
               foo = jsl.foo.new(this) // foo is a Groovy class in JSL
               foo.logIpAddress()   // *** Gets executed on Jenkins Master ***
            }
         }
      }
   }
   post {
      always {
         cleanWs()
      }
   }
}

Solution

  • I posted this question on JenkinsUser google group as well. JSL script gets executed only on Jenkins Master, that's by design.

    More details on -- https://groups.google.com/g/jenkinsci-users/c/t66PLaAvcgw/m/Ruo97K2AAgAJ