This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
100 lines (99 loc) · 3.52 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
//Declarative Jenkinsfile Template: Delete these top lines before merging your Jenkinsfile with master
//Pipeline Syntax Resource: https://jenkins.io/doc/book/pipeline/syntax/
//nodejs used in declarative: https://github.com/buildcom/react-supply-store/blob/master/Jenkinsfile
//maven used in declarative: https://github.com/buildcom/customer-services/blob/master/Jenkinsfile
//Most projects on leroy-npn.fergcs.com are now declarative, so those can be used as reference for your project
//Or you can ask your fellow SREs for assistance :)
pipeline {
agent {
label 'CentOS7'
}
tools {
git 'Latest'
//if your project is maven
maven 'MavenAuto'
//if your project is nodejs, change version accordingly
nodejs 'NodeJS v10+'
}
options {
disableConcurrentBuilds()
parallelsAlwaysFailFast()
}
//Specify Global Environment Variables
//If they need to be changed for all stages in a sub stage, you'll need to do so in a script block as per the Tests Completed stage below
//All variables in the environment block are saved as strings, so you'll need to add .toBoolean() to get boolean values, see Wait for Tests stage
environment {
repositoryName = 'selenium-assessment'
gitRepoUrl = "https://github.com/buildcom/${repositoryName}.git"
testCompletedSuccessfully = false
//mavenCommandOptions = "--fail-at-end --batch-mode --quiet --settings settings.xml -Dmaven.repo.local=.localMavenRepo"
//mavenSettingsConfig = 'org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig1426267345601'
}
stages {
//If you want to use parallel stages, use the below stage to get going, otherwise put the stages in sequential order in this stages block
stage ('Parallel Stages') {
parallel {
stage ('Build and Test') {
//Specifying the agent here makes sure that parallel stages run on different hosts
agent {
label 'CentOS7'
}
//Define variables that will be exclusive to the Build and Test parallel stages.
//You can have the environment block in any stage, but only that stage and it's substages will have access to the new value
environment {
testEnvSpecificVar = 'somevar'
}
stages {
//Build and Test Stages Here
stage ('Tests Completed') {
steps {
script {
testCompletedSuccessfully = true
}
}
}
}
}
//Running in parallel with Build and Test
stage ('Build and Deploy') {
agent {
label 'CentOS7'
}
environment {
deployEnvSpecifiVar = 'someothervar'
}
when {
branch 'master'
}
stages {
//Build and Deploy Stages here
stage ('Wait for Tests') {
options {
timeout(time: 20, unit: 'MINUTES')
}
steps {
waitUntil {
script {
testCompletedSuccessfully.toBoolean()
}
}
}
}
stage ('Jira Label and Git Tag') {
steps {
setJiraLabels(repositoryName)
gitTag gitRepoUrl, repositoryName
}
}
}
}
}
}
}
//post block will run after your build is completed, check the Pipeline Syntax Resource guide for all post block options
post {
cleanup {
cleanWs()
}
}
}