jenkins use other variables in my own shared library -
i'm writing own shared library. want use global variable in code. how can make happen ?
i.e. write class.
class mywork { build() { // here want use global docker(which docker-plugin) docker.dosomething { } } }
enable library in 'global pipeline libraries' (i add library 'pipeline-shared-lib')
create shared-library (with necessary structure)
src/net/kukinet/utils.groovy
package net.kukinet; def myvar = 1 def sayhello() { print ('hello') }
- create pipeline job , create object
jenkinsjob.groovy
#!groovy // need enabled in jenkins configuration ( in: manage jenkins) @library('pipeline-shared-lib') import net.kukinet.* node (){ u = new net.kukinet.utils(); stage('preperations') { print(u.myvar) u.sayhello() } }
Comments
Post a Comment