Evgeny Posted May 3, 2020 Report Share Posted May 3, 2020 Hi, I'm currently trying to setup shared libraries to use different versions. Example use-case: Test job, that will use /main/development branch, where i can experiment with shared libraries and not ruining all production jobs. 1) First of all i tryed to set branch explicitly to "/main/development": It works, as expected. But i can't see this selector in Jenkins log. Log looks loke this, and only in changesets i can see, that new selector actually worked 2) After that a tryed to setup lybrary versions for legacy SCM, as described in documentation (https://www.jenkins.io/doc/book/pipeline/shared-libraries/) Here are shared libraries settings: Build fails with the same error. I tryed: - Default version = "/main" - Default version = "/main/development" - @Library('Default@main/development') in pipeline script Maybe i'm making some stupid error in setup, but i have no means to debug that, as i can't get final selector from log. Log shows only last succesful selector, and that new selector are saved to txt file, that instantly gets deleted. I checked, that both selectors ("/main" and "/main/development"), written explicitly in settings - works as expected. But "${library.Default.version}" shows an error. What i'm doing wrong? Or how i can see actual selector, that are generated in txt file? Link to comment Share on other sites More sharing options...
calbzam Posted May 5, 2020 Report Share Posted May 5, 2020 Quote It works, as expected. But i can't see this selector in Jenkins log. Log looks loke this, and only in changesets i can see, that new selector actually worked The Plastic plugin uses the "cm sts --help command and the selector is taken from a text file (based on the same selector you enter in your configuration panel). If I properly understand, this is properly working. Quote I checked, that both selectors ("/main" and "/main/development"), written explicitly in settings - works as expected. But "${library.Default.version}" shows an error Could you configure your build to "echo ${library.Default.version}"? we need to be sure this value is properly resolved and the format is correct. Anyway, if you want to use shared libraries, please check the steps from "Mikael Kalms" in the following thread: You should be able to repro this by setting up an empty Plastic repo as your Global Shared Library, and another Plastic repo containing a single-line Jenkinsfile: @Library('JenkinsBuildScripts@latest') _ Regards, Carlos. Link to comment Share on other sites More sharing options...
Evgeny Posted May 8, 2020 Author Report Share Posted May 8, 2020 I tryed "echo ${library.Default.version}" and get an error hudson.remoting.ProxyException: groovy.lang.MissingPropertyException: No such property: library for class: WorkflowScript Link to comment Share on other sites More sharing options...
calbzam Posted May 9, 2020 Report Share Posted May 9, 2020 Hi Evgeny, I've running some tests and I don't think this variable will be resolved. In order to use the shared libraries in Plastic, we need to follow the steps from this other thread (Mikael Kalms comment). Quote You should be able to repro this by setting up an empty Plastic repo as your Global Shared Library, and another Plastic repo containing a single-line Jenkinsfile: @Library('JenkinsBuildScripts@latest') _ Then you would set up two Jenkins jobs referencing the latter repo. You can see that the shared library is not configured via enviroment variable in the selector. We can arrange a GoToMeeting to show you this feature in one of our machines. Regards, Carlos. Link to comment Share on other sites More sharing options...
Evgeny Posted May 10, 2020 Author Report Share Posted May 10, 2020 I tryed the same setup with GitHub and it didn't work either. It just checkout the latest changeset. So it looks like some bug in Jenkins. I added 2 different libraries that point to a different branches of the same repository. So now i can't use "Load implicitly" setting, but i can switch shared library on certain jobs to development branch. Link to comment Share on other sites More sharing options...
calbzam Posted May 11, 2020 Report Share Posted May 11, 2020 Hi Evgeny, I've run the following test today: 1. Create the shared library in the Jenkins configuration: 2. I created new Pipeline type build with the following content: 3. This is the content of the Jenkins file I use in the repo. I set the shared library: 4- I run the build and it's succesful. I cannot reproduce any error. Regards, Carlos. Link to comment Share on other sites More sharing options...
Evgeny Posted May 11, 2020 Author Report Share Posted May 11, 2020 Yes, in that case all works well. But how do you select library varsion that way? For example: @Library('myrepo@development') _ @Library('myrepo@v1.0') _ @Library('myrepo@stable') _ etc Link to comment Share on other sites More sharing options...
calbzam Posted May 12, 2020 Report Share Posted May 12, 2020 Hi, I'm including @Mikael Kalms in this thread as I know they are using shared libraries. I've seen the following in the documentation: https://tomd.xyz/jenkins-shared-library/ Quote Hi, How to configure the JSL with different versions in Jenkins, Eg. @Library(JSL_1@1.0) _ instead of master in the version part, need to use git tags. @Library(JSL_1@master) _ Any idea? version is depend on git branch name. More info can check this out https://jenkins.io/doc/book/pipeline/shared-libraries/#library-versions Regards, Carlos. Link to comment Share on other sites More sharing options...
Evgeny Posted May 14, 2020 Author Report Share Posted May 14, 2020 I read this article before. In case of git - it works with tags and only if you use "Modern scm". There are no options for Plastic in "Modern scm". And in "Legacy scm" you only option is to use "${library.Default.version}". And it didn't work even in GIT. Link to comment Share on other sites More sharing options...
calbzam Posted May 14, 2020 Report Share Posted May 14, 2020 In order to select a library version, using the branch name doesn't work as they propose in the previous link? Quote When using the library step you may also specify a version: library 'my-shared-library@master' Since this is a regular step, that version could be computed rather than a constant as with the annotation; for example: library "my-shared-library@$BRANCH_NAME" Regards, Ct'arlos. Link to comment Share on other sites More sharing options...
Evgeny Posted May 15, 2020 Author Report Share Posted May 15, 2020 As i said earlier - i solved my problem by defining 2 different libraries in Jenkins Settings. I'm ok with this workaround. So we can close this topic In case, you want to investigate this further: version selection doesn't work as they propose in the previous link for legacy SCM. I tested it with: - Plastic - returns errors in selector - Github (legacy SCM) - just checksout latest changeset (regardless of brunch) I didn't find any references to someone using library versions on legacy SCM and decided that this is a Jenkins bug, but i didn't created issue on their bug tracker 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now