-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not tag traces with shared libraries Git metadata
- Loading branch information
1 parent
9bd7908
commit 2e29383
Showing
4 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// A script that configures sample Jenkins shared library (https://www.jenkins.io/doc/book/pipeline/shared-libraries/) | ||
|
||
import jenkins.plugins.git.GitSCMSource | ||
import org.jenkinsci.plugins.workflow.libs.GlobalLibraries | ||
import org.jenkinsci.plugins.workflow.libs.LibraryConfiguration | ||
import org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever | ||
|
||
// Define the shared library configuration | ||
def libraryName = "test-shared-lib" | ||
def defaultVersion = "main" | ||
def gitUrl = "[email protected]:DataDog/ci-visibility-test-jenkins-shared-library.git" | ||
def credentialsId = "github-ssh" | ||
|
||
// Create a Git SCM source | ||
def gitSCMSource = new GitSCMSource(null, gitUrl, credentialsId, "*", "", false) | ||
|
||
// Create a retriever using the SCM source | ||
def retriever = new SCMSourceRetriever(gitSCMSource) | ||
|
||
// Create the library configuration | ||
def libraryConfig = new LibraryConfiguration(libraryName, retriever) | ||
libraryConfig.defaultVersion = defaultVersion | ||
libraryConfig.implicit = false | ||
libraryConfig.allowVersionOverride = true | ||
|
||
// Add the library configuration to the global libraries | ||
def globalLibraries = GlobalLibraries.get() | ||
def existingLibraries = globalLibraries.libraries.findAll { it.name != libraryName } | ||
globalLibraries.libraries = existingLibraries + libraryConfig | ||
|
||
println "Global Trusted Pipeline Library '${libraryName}' has been configured." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
docker/controller-node/jobs/test-pipeline-shared-library.cps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@Library("test-shared-lib@main") _ | ||
|
||
pipeline { | ||
agent any | ||
stages { | ||
stage('Hello') { | ||
steps { | ||
sayhello "Alice" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters