Skip to content

Commit bf8ec45

Browse files
authored
Merge pull request jfrog#157 from yahavi/declarative-npm
Add declarative npm example
2 parents 67bf31b + 96cc738 commit bf8ec45

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

Diff for: jenkins-examples/pipeline-examples/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Here are the available examples.
5757
* The [exclude-patterns-upload-example](scripted-examples/exclude-patterns-upload-example) demonstrates how to exclude certain files while uploading.
5858
* The [maven-container-example](scripted-examples/maven-container-example) demonstrates how to run Maven in a Docker container.
5959
* The [gradle-container-example](scripted-examples/gradle-container-example) demonstrates how to run Gradle in a Docker container.
60+
* The [npm-example](scripted-examples/npm-example) resolves dependencies, deploys artifacts and publishes build-info to Artifactory for a npm build.
6061

6162
#### Declarative pipeline examples:
6263
* The [props-example](declarative-examples/props-example) downloads and uploads files to Artifactory with properties. The props-example also uses a placeholder when uploading.
@@ -70,6 +71,6 @@ Here are the available examples.
7071
* The [gradle-example](declarative-examples/gradle-example) resolves dependencies, deploys artifacts and publishes build-info to Artifactory for a Gradle build. Unlike the [gradle-example-ci-server](gradle-example-ci-server), this examples assumes that the Gradle Artifactory Plugin in already applied in the Gradle build script.
7172
* The [exclude-patterns-download-example](declarative-examples/exclude-patterns-download-example) demonstrates how to exclude certain files while downloading.
7273
* The [exclude-patterns-upload-example](declarative-examples/exclude-patterns-upload-example) demonstrates how to exclude certain files while uploading.
73-
74+
* The [npm-example](declarative-examples/npm-example) resolves dependencies, deploys artifacts and publishes build-info to Artifactory for a npm build.
7475

7576
Learn more about [working with pipeline jobs in Jenkins](https://www.jfrog.com/confluence/display/RTF/Working+With+Pipeline+Jobs+in+Jenkins) and the benefits of [Artifactory’s integration with Jenkins CI](https://jfrog.com/integration/jenkins-ci/).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
pipeline {
2+
agent any
3+
4+
stages {
5+
stage ('Clone') {
6+
steps {
7+
git branch: 'master', url: "https://github.com/jfrog/project-examples.git"
8+
}
9+
}
10+
11+
stage ('Artifactory configuration') {
12+
steps {
13+
rtServer (
14+
id: "ARTIFACTORY_SERVER",
15+
url: SERVER_URL,
16+
credentialsId: CREDENTIALS
17+
)
18+
19+
rtNpmResolver (
20+
id: "NPM_RESOLVER",
21+
serverId: "ARTIFACTORY_SERVER",
22+
repo: "npm-remote"
23+
)
24+
25+
rtNpmDeployer (
26+
id: "NPM_DEPLOYER",
27+
serverId: "ARTIFACTORY_SERVER",
28+
repo: "npm-local"
29+
)
30+
}
31+
}
32+
33+
stage ('Exec npm install') {
34+
steps {
35+
rtNpmInstall (
36+
tool: NPM_TOOL, // Tool name from Jenkins configuration
37+
path: "npm-example",
38+
resolverId: "NPM_RESOLVER"
39+
)
40+
}
41+
}
42+
43+
stage ('Exec npm publish') {
44+
steps {
45+
rtNpmPublish (
46+
tool: NPM_TOOL, // Tool name from Jenkins configuration
47+
path: "npm-example",
48+
deployerId: "NPM_DEPLOYER"
49+
)
50+
}
51+
}
52+
53+
stage ('Publish build info') {
54+
steps {
55+
rtPublishBuildInfo (
56+
serverId: "ARTIFACTORY_SERVER"
57+
)
58+
}
59+
}
60+
}
61+
}

Diff for: jenkins-examples/pipeline-examples/npm-example/Jenkinsfile renamed to jenkins-examples/pipeline-examples/scripted-examples/npm-example/Jenkinsfile

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ node {
1010
stage ('Artifactory configuration') {
1111
rtNpm.deployer repo: 'npm-local', server: server
1212
rtNpm.resolver repo: 'npm-remote', server: server
13+
rtNpm.tool = NPM_TOOL // Tool name from Jenkins configuration
1314
buildInfo = Artifactory.newBuildInfo()
1415
}
1516

0 commit comments

Comments
 (0)