-
Notifications
You must be signed in to change notification settings - Fork 9
/
.jenkinsfile
97 lines (97 loc) · 4.33 KB
/
.jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
pipeline {
agent {
label "master"
}
tools {
maven "Maven"
}
environment {
NEXUS_VERSION = "nexus3"
NEXUS_PROTOCOL = "https"
NEXUS_URL = "nexus.seedfinding.com"
NEXUS_REPOSITORY = "maven-latticg"
NEXUS_CREDENTIAL_ID = "nexus-user-creds"
}
stages {
stage("Clone code from VCS") {
steps {
script {
git 'https://github.com/mjtb49/LattiCG.git';
}
}
}
stage("Maven Build") {
steps {
script {
sh "./gradlew publishMavenJavaPublicationToMavenLocal"
}
}
}
stage("Publish to Nexus Repository Manager") {
steps {
script {
def ret = sh(script: 'ls -lR build', returnStdout: true)
println ret
ret = sh(script: 'find . -name \'*.xml\'', returnStdout: true)
println ret
def pomPath="build/publications/mavenJava/pom-default.xml"
pom = readMavenPom file: pomPath;
filesByGlob = findFiles(glob: "build/libs/*.jar");
echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
artifactPath = filesByGlob[0].path;
javadocPath = filesByGlob[1].path;
runtimePath = filesByGlob[2].path;
sourcePath = filesByGlob[3].path;
if(fileExists(artifactPath) && fileExists(javadocPath) && fileExists(sourcePath)) {
echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
echo "*** File: ${javadocPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
echo "*** File: ${runtimePath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
echo "*** File: ${sourcePath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
nexusArtifactUploader(
nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL,
nexusUrl: NEXUS_URL,
groupId: pom.groupId,
version: pom.version,
repository: NEXUS_REPOSITORY,
credentialsId: NEXUS_CREDENTIAL_ID,
artifacts: [
[artifactId: pom.artifactId,
classifier: '',
file: artifactPath,
type: pom.packaging],
[artifactId: pom.artifactId,
classifier: 'javadoc',
file: javadocPath,
type: pom.packaging],
[artifactId: pom.artifactId,
classifier: 'sources',
file: sourcePath,
type: pom.packaging],
[artifactId: pom.artifactId,
classifier: 'rt',
file: runtimePath,
type: pom.packaging],
[artifactId: pom.artifactId,
classifier: '',
file: pomPath,
type: "pom"]
]
);
} else {
error "*** File: ${artifactPath}, could not be found";
}
}
}
}
stage('Upload'){
steps {
withCredentials([usernameColonPassword(credentialsId: 'ftplogin', variable: 'FTP')]) {
script {
sh "cd build/docs/javadoc && find . -type f -exec curl -k --ssl-reqd -u ${FTP} --ftp-create-dirs -T {} ftp://<ip>:8021/{} \\; "
}
}
}
}
}
}