-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
97 lines (87 loc) · 3.41 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
openshift.withCluster() {
env.NAMESPACE = openshift.project()
env.APP_NAME = "${JOB_NAME}".replaceAll(/-build.*/, '')
echo "Starting Pipeline for ${APP_NAME}..."
env.BUILD = "${env.NAMESPACE}"
env.DEV = "${env.DEV_NAMESPACE}"
}
podTemplate(
label: "dotnet-pod",
cloud: "openshift",
serviceAccount: "jenkins",
containers: [
containerTemplate(
name: "jnlp",
image: "registry.redhat.io/openshift3/jenkins-agent-maven-35-rhel7:v3.11"
),
containerTemplate(
name: "nodejs",
image: "registry.redhat.io/rhel8/nodejs-12:latest",
ttyEnabled: true,
command: 'cat',
resourceLimitCpu: '1',
resourceLimitMemory: '1Gi',
resourceRequestMemory: '256Mi'
),
containerTemplate(
name: 'dotnet',
image: 'registry.redhat.io/dotnet/dotnet-22-rhel7:2.2',
ttyEnabled: true,
command: 'cat'
)
]) {
node("dotnet-pod") {
container('dotnet') {
// Checkout source code
// This is required as Pipeline code is originally checkedout to
// Jenkins Master but this will also pull this same code to this slave
stage('Git Checkout') {
// Turn off Git's SSL cert check, uncomment if needed
// sh 'git config --global http.sslVerify false'
git url: "${APPLICATION_SOURCE_REPO}", branch: "${APPLICATION_SOURCE_REF}"
}
stage('Build JS frontend') {
def apiHostName = "";
container("nodejs") {
dir("ui") {
sh 'npm install'
sh 'npm run-script build'
}
}
}
// Run Maven build, skipping tests
stage('publish') {
dir('api') {
sh '''
export PATH=/opt/rh/rh-dotnet22/root/usr/bin:$PATH
dotnet publish -c Release /p:MicrosoftNETPlatformLibrary=Microsoft.NETCore.App
'''
}
}
// Build Container Image using the artifacts produced in previous stages
stage('Build Container Images'){
// Build container image using local Openshift cluster
// Giving all the artifacts to OpenShift Binary Build
// This places your artifacts into right location inside your S2I image
// if the S2I image supports it.
container("jnlp") {
openshift.withCluster() {
openshift.selector("bc", "dot-net-auth").startBuild("--from-dir=api/bin/Release/netcoreapp2.2/publish", "--wait")
openshift.selector("bc", "dot-net-auth-ui").startBuild("--from-dir=ui/dist", "--wait")
}
}
}
stage('Promote from Build to Dev') {
container("jnlp") {
openshift.withCluster() {
openshift.tag("${env.BUILD}/dot-net-auth:latest", "${env.DEV}/dot-net-auth:latest")
openshift.tag("${env.BUILD}/dot-net-auth-ui:latest", "${env.DEV}/dot-net-auth-ui:latest")
}
}
}
// stage ('Verify Deployment to Dev') {
// verifyDeployment(projectName: env.DEV, targetApp: "${APP_NAME}-web")
// }
}
}
}