Skip to content

Commit 5ff0f9f

Browse files
author
R. Tyler Croy
authored
Merge pull request jenkinsci#63 from eyalbe4/master
Artifactory Examples
2 parents c88982a + 063aef3 commit 5ff0f9f

File tree

6 files changed

+104
-0
lines changed

6 files changed

+104
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Synopsis
2+
3+
This is a simple demonstration of how to download dependencies, upload artifacts and publish build info to Artifactory.
4+
<br>
5+
Read the full documentation [here](https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
node {
2+
git url: 'https://github.com/jfrogdev/project-examples.git'
3+
4+
// Get Artifactory server instance, defined in the Artifactory Plugin administration page.
5+
def server = Artifactory.server "SERVER_ID"
6+
7+
// Read the upload spec and upload files to Artifactory.
8+
def downloadSpec =
9+
'''{
10+
"files": [
11+
{
12+
"pattern": "libs-snapshot-local/*.zip",
13+
"target": "dependencies/,
14+
"props": "p1=v1;p2=v2"
15+
}
16+
]
17+
}'''
18+
19+
def buildInfo1 = server.download spec: downloadSpec
20+
21+
// Read the upload spec which was downloaded from github.
22+
def uploadSpec =
23+
'''{
24+
"files": [
25+
{
26+
"pattern": "resources/Kermit.*",
27+
"target": "libs-snapshot-local",
28+
"props": "p1=v1;p2=v2"
29+
},
30+
{
31+
"pattern": "resources/Frogger.*",
32+
"target": "libs-snapshot-local"
33+
}
34+
]
35+
}'''
36+
37+
// Upload to Artifactory.
38+
def buildInfo2 = server.upload spec: uploadSpec
39+
40+
// Merge the upload and download build-info objects.
41+
buildInfo1.append buildInfo2
42+
43+
// Publish the build to Artifactory
44+
server.publishBuildInfo buildInfo1
45+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Synopsis
2+
3+
This is a simple demonstration of how to run a Gradle build, that resolves dependencies, upload artifacts and publish build info to Artifactory.
4+
<br>
5+
Read the full documentation [here](https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin).
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
node {
2+
// Get Artifactory server instance, defined in the Artifactory Plugin administration page.
3+
def server = Artifactory.server "SERVER_ID"
4+
// Create an Artifactory Gradle instance.
5+
def rtGradle = Artifactory.newGradleBuild()
6+
7+
stage 'Clone sources'
8+
git url: 'https://github.com/jfrogdev/project-examples.git'
9+
10+
stage 'Artifactory configuration'
11+
// Tool name from Jenkins configuration
12+
rtGradle.tool = "Gradle-2.4"
13+
// Set Artifactory repositories for dependencies resolution and artifacts deployment.
14+
rtGradle.deployer repo:'ext-release-local', server: server
15+
rtGradle.resolver repo:'remote-repos', server: server
16+
17+
stage 'Gradle build'
18+
def buildInfo = rtGradle.run rootDir: "gradle-examples/4/gradle-example-ci-server/", buildFile: 'build.gradle', tasks: 'clean artifactoryPublish'
19+
20+
stage 'Publish build info'
21+
server.publishBuildInfo buildInfo
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Synopsis
2+
3+
This is a simple demonstration of how to run a Maven build, that resolves dependencies, upload artifacts and publish build info to Artifactory.
4+
<br>
5+
Read the full documentation [here](https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin).
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
node {
2+
// Get Artifactory server instance, defined in the Artifactory Plugin administration page.
3+
def server = Artifactory.server "SERVER_ID"
4+
// Create an Artifactory Maven instance.
5+
def rtMaven = Artifactory.newMavenBuild()
6+
7+
stage 'Clone sources'
8+
git url: 'https://github.com/jfrogdev/project-examples.git'
9+
10+
stage 'Artifactory configuration'
11+
// Tool name from Jenkins configuration
12+
rtMaven.tool = "Maven-3.3.9"
13+
// Set Artifactory repositories for dependencies resolution and artifacts deployment.
14+
rtMaven.deployer releaseRepo:'libs-release-local', snapshotRepo:'libs-snapshot-local', server: server
15+
rtMaven.resolver releaseRepo:'libs-release', snapshotRepo:'libs-snapshot', server: server
16+
17+
stage 'Maven build'
18+
def buildInfo = rtMaven.run pom: 'maven-example/pom.xml', goals: 'clean install'
19+
20+
stage 'Publish build info'
21+
server.publishBuildInfo buildInfo
22+
}

0 commit comments

Comments
 (0)