From af5323092c86173f89a874e2a91bbde40ec9b5f1 Mon Sep 17 00:00:00 2001 From: "aleksandr.vodyanov" Date: Tue, 29 Aug 2023 15:41:07 +0300 Subject: [PATCH] first commit --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..31de1e0 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# jenkins-pipeline-shared-lib + +### Docs: + +[Jenkins Shared Libraries](https://www.jenkins.io/doc/book/pipeline/shared-libraries/) + +[Pipeline CPS Method Mismatches](https://www.jenkins.io/doc/book/pipeline/cps-method-mismatches/) + +[Pipeline Best Practices](https://www.jenkins.io/doc/book/pipeline/pipeline-best-practices/) + +[Документирование классов в Java](https://java-online.ru/java-javadoc.xhtml) + +### Directory structure +The directory structure of a Shared Library repository is as follows: +``` +(root) ++- src # Groovy source files +| +- org +| +- foo +| +- Bar.groovy # for org.foo.Bar class ++- vars +| +- foo.groovy # for global 'foo' variable +| +- foo.txt # help for 'foo' variable ++- resources # resource files (external libraries only) +| +- org +| +- foo +| +- bar.json # static helper data for org.foo.Bar +``` + +The `src` directory should look like standard Java source directory structure. This directory is added to the classpath when executing Pipelines. + +The `vars` directory hosts script files that are exposed as a variable in Pipelines. The name of the file is the name of the variable in the Pipeline. So if you had a file called `vars/log.groovy` with a function like `def info(message)…` in it, you can access this function like `log.info "hello world"` in the Pipeline. You can put as many functions as you like inside this file. Read on below for more examples and options. + +The basename of each `.groovy` file should be a Groovy (~ Java) identifier, conventionally `camelCased`. The matching `.txt`, if present, can contain documentation, processed through the system’s configured markup formatter (so may really be HTML, Markdown, etc., though the `.txt` extension is required). This documentation will only be visible on the Global Variable Reference pages that are accessed from the navigation sidebar of Pipeline jobs that import the shared library. In addition, those jobs must run successfully once before the shared library documentation will be generated. + +The Groovy source files in these directories get the same “CPS transformation” as in Scripted Pipeline. + +A `resources` directory allows the `libraryResource` step to be used from an external library to load associated non-Groovy files. Currently this feature is not supported for internal libraries.