-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile_2
More file actions
68 lines (60 loc) · 1.82 KB
/
Copy pathJenkinsfile_2
File metadata and controls
68 lines (60 loc) · 1.82 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
pipeline {
agent {
label 'agent1' // Use the label 'agent' to target your Jenkins slave
}
environment {
GIT_REPO = 'git@github.com:zaftechnologies/git-practice.git'
DIRECTORY_NAME = 'artifact' // Name of the directory where repo will be cloned
}
stages {
stage('Clone Repository') {
steps {
// Checkout the Git repository with SSH key authentication
git branch: 'main',
credentialsId: 'github-ssh-key',
url: "${GIT_REPO}"
}
}
stage('verify') {
steps {
// Print the current working directory to debug
sh 'ls hello_world.sh'
sh 'ls' // List the contents to confirm the repo is
sh 'pwd'
sh 'mkdir -p artifact'
sh 'echo Hello > artifact/test.txt'
}
}
stage('HelloWorld') {
steps {
// Print HelloWorld
sh 'sh hello_world.sh'
}
}
stage('Create tar.gz Archive') {
steps {
script {
// Create zip file
sh "tar -czf ${DIRECTORY_NAME}.tar.gz ${DIRECTORY_NAME}"
}
}
}
stage('Archive the tar.gz File') {
steps {
// Archive the tar.gz file as a build artifact
archiveArtifacts artifacts: '*.tar.gz', allowEmptyArchive: true
}
}
}
post {
always {
echo 'Pipeline execution complete.'
}
success {
echo 'Pipeline executed successfully!'
}
failure {
echo 'Pipeline failed. Check logs for details.'
}
}
}