no, it is not possible, the groovy code is executed in the Jenkins
controller by design, it is designed to execute simple logic of
orchestration logic, if you want to execute heavy logic you should do it on
the agents by using steps that run scripts or processes on the agent.
pipeline {
agent { label 'scdc-generic-w10x64' }
options {
timestamps()
}
stages {
stage('Log ip') {
steps {
script {
bat "ipconfig -all" // *** Gets executed on Jenkins Agent
***
def stdout = bat(returnStdout: true, script: "*groovy
*my-script.groovy"
// *** Gets executed on Jenkins Agent ***
echo "stdout"
}
}
}
}
post {
always {
cleanWs()
}
}
}
the script can be whatever you want groovy, python, PowerShell, or a simple
binary, the only that you have to have is the script interpreter installed
in your Jenkins agent
take a look at this fantastic Jesse Glick presentation to know why
https://www.youtube.com/watch?v=Zeqc6--0eQw
El martes, 13 de julio de 2021 a las 22:49:57 UTC+2, [email protected]
escribió:
> I have a question regarding the execution of JSL scripts on the Jenkins
> Agent node. I noticed JSL scripts get executed only on Jenkins Master, is
> it possible to run the 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 using “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()
> }
> }
> }
>
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/d1113336-ac16-4137-b30a-754e3005df76n%40googlegroups.com.