forked from Nithin2751/static_website_practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
67 lines (60 loc) · 1.75 KB
/
Jenkinsfile
File metadata and controls
67 lines (60 loc) · 1.75 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
pipeline {
agent any
environment {
SONARQUBE_ENV = 'SonarQube'
NEXUS_REPO_URL = 'http://3.7.254.85:30801/#browse/search/maven/'
NEXUS_CREDENTIALS_ID = 'nexus-creds'
}
tools {
maven 'maven3'
}
stages {
stage('Checkout Code') {
steps {
git(
branch: "main", url: "https://github.com/swathi6327/static_website_practice.git",
credentialsId: 'GIT-CRED'
)
}
}
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv("${SONARQUBE_ENV}") {
sh 'mvn clean verify sonar:sonar'
}
}
}
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Manual Approval for Deployment') {
steps {
input message: "Approve to deploy artifact to Nexus repository?", ok: "Deploy"
}
}
stage('Upload to Nexus') {
steps {
withCredentials([usernamePassword(
credentialsId: "${nexus-creds}",
usernameVariable: 'admin',
passwordVariable: 'admin'
)]) {
sh """
curl -u $NEXUS_USER:$NEXUS_PASS --upload-file target/your-artifact.jar \
${NEXUS_REPO_URL}/com/yourorg/your-artifact/1.0/your-artifact-1.0.jar
"""
}
}
}
}
post {
success {
echo 'Pipeline executed successfully!'
}
failure {
echo 'Pipeline failed.'
}
}
}