Pipeline job with shared library version as parameter?

22 views
Skip to first unread message

Torsten Reinhard

unread,
Nov 29, 2016, 10:45:20 AM11/29/16
to Jenkins Users
Hi,

I want to setup a pipeline for our shared groovy library. It looks like

node ('master') {
   
...    
    stage
"CI: Build, unit test"
    ciBuildTest
()
   
    stage
"CI: Integration test (${env.INTEGRATIONTEST_PIPELINE})"
   
// INTEGRATIONTEST_PIPELINE is a property of the job running this file.
   
// enables switching of the integration test project without modification to the Jenkinsfile itself.
    println
"will start now '${env.INTEGRATIONTEST_PIPELINE}' for integration tests."
   
   
// TODO pass this BRANCHNAME so the triggered job will use shared library from this branch.
    build job
: "${env.INTEGRATIONTEST_PIPELINE}", propagate: true, wait: true, parameters: []
   
...    
}

The job gets triggered - but now I need an option to pass the current branch $env.BRANCHNAME to the triggered job.
Especially, I need to reference the shared library than.

I added a parameter "String: SHARED_LIB_VERSION" to the triggered job, with "master" as default:
Inside this job, I tried to reference the lib using the annotation way:

@Library("sharedLibrary@$SHARED_LIB_VERSION")
import myFunctions
....

But i couldnt get this to work.

Is there a way to pass the version of the shared library to a job ? Or to the folder, the job is in ?

Thanx for any help,

Torsten

Reply all
Reply to author
Forward
0 new messages