-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
177 lines (147 loc) · 4.21 KB
/
Jenkinsfile
File metadata and controls
177 lines (147 loc) · 4.21 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
pipeline{
agent any
/* agent {
// node {
// label 'master'
// }
docker {
image 'maven'
label 'master'
args '-v $HOME/.m2:/root/m2'
}
}*/
parameters {
choice(
// choices are a string of newline separated values
// https://issues.jenkins-ci.org/browse/JENKINS-41180
name: 'REQUESTED_ACTION',
choices: 'create\nupdate',
description: '')
choice(
// choices are a string of newline separated values
// https://issues.jenkins-ci.org/browse/JENKINS-41180
name: 'percentage',
choices: '100\n50',
description: '')
}
options {
timeout(time: 30,unit: 'MINUTES')
disableConcurrentBuilds()
}
environment {
VARIABLE = 'roshmi'
}
stages{
stage('build')
{
steps{
script{
echo "Helloo"
echo 'Pulling...' + env.BRANCH_NAME
sh "mvn clean -Dmaven.test.skip"
}
}
}
// How to initialize software and set path
//Go to global tool configuration and add the tool
/* stage('maven')
{
steps
{
script
{
def mvnHome = tool name: 'maven'
env.PATH = "${mvnHome}:${env.PATH}"
}
sh 'mvn --version'
echo '$env.PATH is = ' + env.PATH
}
}*/
stage('choice_dropdown')
{
when {
expression {params.REQUESTED_ACTION == 'create'}
}
steps{
script{
echo 'create selected'
}
}
}
stage('Example') {
input {
message "Should we continue?"
ok "Yes, we should."
//submitter "alice,bob"
parameters {
string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')
string(name: 'PASSWORD', defaultValue: 'Mr Jenkins', description: 'pass')
}
}
steps {
echo "Hello, ${PERSON}, nice to meet you."
//writeFile file: "/Users/roshmi.b/Desktop/inputData.txt", text: "Config=${PERSON}\r\nTest=${PASSOWRD}"
//archiveArtifacts '/Users/roshmi.b/Desktop/inputData.txt'
}
}
stage('env_variable') {
steps {
script{
sh 'printenv'
echo env.VARIABLE
}
}
}
// to deploy:- Jenikins-->Manage Jenkins-->Manage files-->Maven settings.xml
/* stage('build2') {
steps {
script{
def pom = readMavenPom file: 'pom.xml' //returned object is a model
def ver = pom['version'] //${pom.version} --> extracting the value from the model object
def mvn_dir = "/usr/bin/mvn"
def branch = env.GIT_BRANCH
echo "version is ${ver}"
echo "branch is ${branch}"
if (branch.contains('master') && ver.contains('SNAPSHOT')){
configFileProvider([configFile(fileId: 'myconfig', variable: 'MyGlobalSettings')]) {
sh "mvn install -Dmaven.test.skip=true -s $MyGlobalSettings" }
}
}
}
}
*/
stage('build2') {
environment{
//pom = "${readMavenPom file: 'pom.xml'} " //returned object is a model
ver = readMavenPom().getVersion() //${pom.version} --> extracting the value from the model object
mvn_dir = "/usr/bin/mvn"
branch = "${env.GIT_BRANCH}"
}
steps{
echo "version is ${ver}"
echo "branch is ${branch}"
configFileProvider([configFile(fileId: 'myconfig', variable: 'MyGlobalSettings')]) {
sh "mvn install -Dmaven.test.skip=true -s $MyGlobalSettings" }
}
when {
environment ignoreCase: true, name: 'branch', value: 'origin/master'
}
post {
always {
echo "branch is ${branch}"
}
}
}
}
post{
always{
echo "from always block"
}
success{
echo "from success block"
}
failure{
echo "Send eamil as its failed "
}
}
}