I know using Groovy, Jenkins Pipeline Shared library can be developed.
I want to know if there is any way the same Jenkins pipeline shared library can be developed using Java or any other technology?
You build groovy shared library and import your Java library by using Grab.
See example how to import yaml library:
#Grab(group = 'org.yaml', module='snakeyaml', version = "1.18")
import org.yaml.snakeyaml.Yaml
Be sure that library jar file in Jenkins classpath.
Works for me with Jenkins 2.150.1
Related
I have added some changes to x-jenkins groovy file which is to call y-jenkins functions (.groovy files under /var. in y-jenkins repo) - sorry if my terminology is correct as I am not familiar with jenkins. Now in my pipeline's jenkinsfile, used below to try to import from y-jenkinsfile
#Library('x-jenkinsfile#master') _
#Library('y-Jenkinsfile#master')
Due to above its importing all the functions in y-jenkins and conflicting with x-jenkins functions having same names. Is there any way to import specific functions/methods (.groovy files under /var. in y-jenkins repo) into my jenkinsfile?
Could not find the info I am looking for in this link - https://www.jenkins.io/doc/book/pipeline/shared-libraries/
I use Bazel to build my Beam pipeline. The pipeline works well using the DirectRunner, however, I have some trouble managing dependencies when I use DataflowRunner, Python can not find local dependencies (e.g. generated by py_library) in DataflowRunner. Is there any way to hint Dataflow to use the python binary (py_binray zip file) in the worker container to resolve the issue?
Thanks,
Please see here for more details on setting up dependencies for Python SDK on Dataflow. If you are using a local dependency, you should probably look into developing a Python package and using the extra_package option or developing a custom container.
I would like to define some groovy code that is imported into one or more declarative pipelines that are all stored in the same git repo.
I do NOT want to create a global shared library that different pipelines from different repos share.
For example, in a repo I might have the following files:
shared-library.groovy
pr-pipeline-unit-tests.groovy
pr-pipeline-ui-tests.groovy
I want both pr-pipeline-unit-tests.groovy and pr-pipeline-ui-tests.groovy to be able to import shared-library.groovy.
These pipelines are executed on PRs, and updates to shared-library.groovy should only affect that PR - this is why I do not want a jenkins globally stored shared library.
As bonus, it would be cool if shared-library.groovy could be a standalone gradle project that is "imported" into the pipelines, similar to how buildSrc is imported into gradle project configuration files. Even better if the shared code could be Kotlin!
In my Jenkins shared library how can I import java jar class file. I have helper function written in Java and have it as jar fie. How can I include this jar file part of my Jenkins shared library?
Included jar file in resources Directory but pipeline script not finding the class file. giving unable to resolve class error message.
Thanks
SR
This is the Generic way of referring a Jenkins shared library.
// Jenkinsfile
#Library('first-shared-lib')
You may try using libraryResource step in your pipeline script as:
libraryResource './resource/abc.jar'
Following
https://jenkins.io/blog/2017/02/15/declarative-notifications/
I use in my java project a shared library vars/sendNotification.groovy that is used in a jenkins pipeline in src/main/resources/pipeline.
I got this folder structure from
https://jenkins.io/doc/book/pipeline/shared-libraries/
Is it somehow possible to put the groovy script in src/main/resources/ as well? On jenkins -> configuration -> Global Pipeline Libraries it doesn't give me options to specify a path of the shared library (the groovy script)
Thanks!