forked from paulphilip/pythoncode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkinsfile
More file actions
52 lines (45 loc) · 1.54 KB
/
jenkinsfile
File metadata and controls
52 lines (45 loc) · 1.54 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
pipeline {
agent any
stages {
stage('Clean Workspace') {
steps {
cleanWs()
}
}
stage('Checkout') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: '*/main']],
userRemoteConfigs: [[url: 'https://github.com/paulphilip/pythoncode.git']],
extensions: [[$class: 'CloneOption', noTags: false, shallow: true, depth: 1, reference: '', timeout: 10]]])
}
}
stage('Hello') {
steps {
echo 'Hello World'
script {
def fNAME = 'John'
def LName = 'Doe'
echo "${fNAME} ${LName}"
}
}
}
stage('Create Directory and Add Files') {
steps {
script {
// Create a directory in /home
sh 'sudo mkdir -p /home/mydirectory'
// Ensure Jenkins user has permission to write to the directory
sh 'sudo chown -R jenkins:jenkins /home/mydirectory'
// Navigate into the directory and add files
dir('/home/mydirectory') {
sh 'touch file1.txt'
sh 'echo "Hello, world!" > file1.txt'
// List the files in the directory
sh 'ls -la'
}
}
}
}
}
}