Skip to content

Commit

Permalink
Add an example how to test shared pipeline library changes (jenkins-i…
Browse files Browse the repository at this point in the history
…nfra#6585)

* Add an example how to test shared pipeline library changes

* add precision about github hosting.

Co-authored-by: Mark Waite <mark.earl.waite@gmail.com>

* /s/functionality/feature

Co-authored-by: Mark Waite <mark.earl.waite@gmail.com>

* re-word the sentence for structure/grammar

Co-authored-by: Kevin Martens <99040580+kmartens27@users.noreply.github.com>

* escape first `_`

* asciidoc hard break

* fix Bitbucket case

* fix italic

* the fix of in situ broke the underscore escape (╯°□°)╯︵ ┻━┻

* apply review suggestion

* complete sentence with scm config

Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>

* fix jenkins-infra-test-plugin link

* s/the/a

---------

Co-authored-by: Mark Waite <mark.earl.waite@gmail.com>
Co-authored-by: Kevin Martens <99040580+kmartens27@users.noreply.github.com>
Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>
  • Loading branch information
4 people authored Aug 4, 2023
1 parent fd2a681 commit ed4e32e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions content/doc/book/pipeline/shared-libraries.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -700,3 +700,29 @@ Only entire ``pipeline``s can be defined in shared libraries as of this time.
This can only be done in `vars/*.groovy`, and only in a `call` method. Only one
Declarative Pipeline can be executed in a single build, and if you attempt to
execute a second one, your build will fail as a result.

=== Testing library pull request changes

By adding `@Library('my-shared-library@pull/<your-pr-number>/head') _` at the top of a library consumer Jenkinsfile, you can test your pipeline library pull request changes __in situ__ if your pipeline library is hosted on GitHub and the SCM configuration for the pipeline library uses GitHub. +
Refer to the pull request or merge request branch naming convention for other providers like Assembla, Bitbucket, Gitea, GitLab, and Tuleap.

Take, for example, a change to the global ci.jenkins.io shared pipeline, which has its source code stored at https://github.com/jenkins-infra/pipeline-library/.

Let's say you're writing a new feature and opened a pull request on the pipeline library, number `123`.

By opening a pull request on https://github.com/jenkinsci/jenkins-infra-test-plugin/[the dedicated `jenkins-infra-test-plugin` test repository] with the following content, you'll be able to check your changes on ci.jenkins.io:

[source,diff]
----
--- jenkins-infra-test-plugin/Jenkinsfile
+++ jenkins-infra-test-plugin/Jenkinsfile
@@ -1,3 +1,4 @@
+ @Library('pipeline-library@pull/123/head') _
buildPlugin(
useContainerAgent: true,
configurations: [
[platform: 'linux', jdk: 17],
[platform: 'windows', jdk: 11],
])
----

0 comments on commit ed4e32e

Please sign in to comment.