-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
138 lines (127 loc) · 4.62 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
properties([
parameters([
string(name: 'DOCKER_REGISTRY_DOWNLOAD_URL', defaultValue: 'nexus-docker-private-group.ossim.io', description: 'Repository of docker images')
]),
pipelineTriggers([[$class: "GitHubPushTrigger"]]),
[$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://github.com/ossimlabs/omar-core'],
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '3', daysToKeepStr: '', numToKeepStr: '20')),
disableConcurrentBuilds()
])
podTemplate(
containers: [
containerTemplate(
name: 'docker',
image: 'docker:19.03.11',
ttyEnabled: true,
command: 'cat',
privileged: true
),
containerTemplate(
image: "${DOCKER_REGISTRY_DOWNLOAD_URL}/alpine/helm:3.2.3",
name: 'helm',
command: 'cat',
ttyEnabled: true
),
containerTemplate(
name: 'git',
image: 'alpine/git:latest',
ttyEnabled: true,
command: 'cat',
envVars: [
envVar(key: 'HOME', value: '/root')
]
)
],
volumes: [
hostPathVolume(
hostPath: '/var/run/docker.sock',
mountPath: '/var/run/docker.sock'
),
]
) {
node(POD_LABEL) {
stage("Checkout branch") {
scmVars = checkout(scm)
GIT_BRANCH_NAME = scmVars.GIT_BRANCH
BRANCH_NAME = """${sh(returnStdout: true, script: "echo ${GIT_BRANCH_NAME} | awk -F'/' '{print \$2}'").trim()}"""
sh """
touch buildVersion.txt
grep buildVersion gradle.properties | cut -d "=" -f2 > "buildVersion.txt"
"""
preVERSION = readFile "buildVersion.txt"
VERSION = preVERSION.substring(0, preVERSION.indexOf('\n'))
GIT_TAG_NAME = "omar-core" + "-" + VERSION //webhook stuff
ARTIFACT_NAME = "ArtifactName"
script {
if (BRANCH_NAME == 'master') {
TAG_NAME = VERSION
buildName "${VERSION} - ${BRANCH_NAME}"
} else {
TAG_NAME = BRANCH_NAME + "-" + System.currentTimeMillis()
buildName "${VERSION} - ${BRANCH_NAME}-SNAPSHOT"
}
}
}
stage("Load Variables") {
withCredentials([string(credentialsId: 'o2-artifact-project', variable: 'o2ArtifactProject')]) {
step([$class : "CopyArtifact",
projectName: o2ArtifactProject,
filter : "common-variables.groovy",
flatten : true])
}
load "common-variables.groovy"
DOCKER_IMAGE_PATH = "${DOCKER_REGISTRY_PRIVATE_UPLOAD_URL}/omar-core"
}
stage("Assemble") {
sh """
./gradlew assemble -PossimMavenProxy=${MAVEN_DOWNLOAD_URL} -PbranchName=${BRANCH_NAME}
"""
archiveArtifacts "plugins/*/build/libs/*.jar"
//archiveArtifacts "apps/*/build/libs/*.jar"
}
stage("Publish Nexus") {
withCredentials([[$class : 'UsernamePasswordMultiBinding',
credentialsId : 'nexusCredentials',
usernameVariable: 'MAVEN_REPO_USERNAME',
passwordVariable: 'MAVEN_REPO_PASSWORD']]) {
sh """
./gradlew publish -PossimMavenProxy=${MAVEN_DOWNLOAD_URL} -PbranchName=${BRANCH_NAME}
"""
}
}
/*
stage ("Publish Docker App")
{
withCredentials([[$class: 'UsernamePasswordMultiBinding',
credentialsId: 'dockerCredentials',
usernameVariable: 'DOCKER_REGISTRY_USERNAME',
passwordVariable: 'DOCKER_REGISTRY_PASSWORD']])
{
// Run all tasks on the app. This includes pushing to OpenShift and S3.
sh """
./gradlew pushDockerImage \
-PossimMavenProxy=${MAVEN_DOWNLOAD_URL}
"""
}
}
try {
stage ("OpenShift Tag Image")
{
withCredentials([[$class: 'UsernamePasswordMultiBinding',
credentialsId: 'openshiftCredentials',
usernameVariable: 'OPENSHIFT_USERNAME',
passwordVariable: 'OPENSHIFT_PASSWORD']])
{
// Run all tasks on the app. This includes pushing to OpenShift and S3.
sh """
./gradlew openshiftTagImage \
-PossimMavenProxy=${MAVEN_DOWNLOAD_URL}
"""
}
}
} catch (e) {
echo e.toString()
}
*/
}
}