Replaying a dynamically loaded library will load the latest version of the library and not the library available at the time of the build.
Reproduction Steps:
(1) Submit following file to Perforce:
//depot/lib_autoload/libs/src/com/f5/v4/Device.groovy
#!groovy package com.f5.v4class Device implements Serializable { static void main() { println("This is Device in the Library I EDITED THIS.") } static void test() { println("This is test in Device in the Library") } static String test2() { return "This is test2() in Device in the Library" } }
(2) Create a pipeline job with code similar to:
def f5Lib timestamps{ try { node ('master') { f5Lib = loadF5Lib() def buildData = f5Lib.com.f5.v4.Device.test2(); echo buildData } } catch (e) { throw e } echo "Running some tests here..." } // Load a specific Library def loadF5Lib() { def lib = library( identifier : '@now',retriever: modernSCM(globalLib(charset: 'none', credential: 'JenkinsMaster', id: '9bb4320c-c31c-46ce-8c5f-68872f519067', path: '//depot/lib_autoload/libs/...'))) return lib }
(3) Run the job (Build#1). The following text is seen in the console log:
This is test2() in Device in the Library
(4) Change the returned text in the library method ' test2' to be:
static String test2() { return "This is the edited test2() in Device in the Library" }
(5) Run the job (Build #2)
(6) Replay Build #1. The text displayed is the latest text from the edit made in step (4):
This is the edited test2() in Device in the Library
Expected Result:
This is test2() in Device in the Library