You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Objective is to have certain methods which are recursive even among the shared lib files to be kept inside tools class. and call them onto the shared lib files.
Objective is to have certain methods which are recursive even among the shared lib files to be kept inside tools class. and call them onto the shared lib files.
Jenkinsfile:
@Library('shared-library') _
pipeline {
agent any
parameters {
choice(name: 'CHOICES', choices: ['one', 'two', 'three'], description: '')
booleanParam(name: 'DEBUG_BUILD', defaultValue: false, description: '')
}
stages {
stage("Test") {
steps {
script {
command label: 'running sleep', 'sleep 10'
}
}
post {
always {
cleanWs()
}
}
}
}
}
Shared lib file: command.groovy
#!/usr/bin/env groovy
import tools
t = new tools()
def call(Map args = [:], String script) {
script = "${args.sudo ? 'sudo ' : ''}${script}"
def label = args.label ?: script
sh label: label, script: script
}
Utility groovy class:
class tools {
def printHello(arg) {
echo "${arg}"
}
}
The text was updated successfully, but these errors were encountered: