Skip to content

Commit 84a85db

Browse files
eyalbe4eyalbe4
eyalbe4
authored and
eyalbe4
committed
Artifactory examples.
1 parent c88982a commit 84a85db

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 which was downloaded from github.
8+
def uploadSpec =
9+
'''{
10+
"files": [
11+
{
12+
"pattern": "resources/Kermit.*",
13+
"target": "libs-snapshot-local",
14+
"props": "p1=v1;p2=v2"
15+
},
16+
{
17+
"pattern": "resources/Frogger.*",
18+
"target": "libs-snapshot-local"
19+
}
20+
]
21+
}'''
22+
23+
// Upload to Artifactory.
24+
def buildInfo1 = server.upload spec: uploadSpec
25+
26+
// Read the upload spec and upload files to Artifactory.
27+
def downloadSpec =
28+
'''{
29+
"files": [
30+
{
31+
"pattern": "libs-snapshot-local/*.zip",
32+
"target": "dependencies/,
33+
"props": "p1=v1;p2=v2"
34+
}
35+
]
36+
}'''
37+
38+
def buildInfo2 = server.download spec: downloadSpec
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 'Exec Gradle'
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 'Exec Maven'
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)