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 {        }    } } 

  1. enable library in 'global pipeline libraries' (i add library 'pipeline-shared-lib')

  2. create shared-library (with necessary structure)

src/net/kukinet/utils.groovy

package net.kukinet;  def myvar = 1 def sayhello() {     print ('hello') } 
  1. 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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -