Jenkins 代理节点上的 Jenkins 共享库脚本

问题描述

我注意到 JSL 脚本只能在 Jenkins Master 上执行,是否可以在 Jenkins Agent 上运行 JSL 脚本?

我的管道中有多个阶段,我希望在不同的 Jenkins 代理节点上运行这些阶段。

我使用 JSL 的主要动机是 end-to-end Pipeline testability 在开发过程中使用“重播”,我可以在其中修改 Jenkinsfile 以及来自 JSL 的脚本。

这是我的流水线的一个片段 --

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()
      }
   }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)