-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcall-job1-from-job2.groovy
63 lines (57 loc) · 1.94 KB
/
call-job1-from-job2.groovy
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
pipeline {
agent any
stages {
stage('CI - Compile and Test') {
steps {
script {
// Compile code, run tests, and build the JAR
sh 'mvn clean package'
}
}
}
stage('Trigger JOB-1') {
steps {
build job: 'JOB-1', wait: true
}
}
stage('Upload JAR to Artifactory') {
steps {
script {
// Upload the built JAR to Artifactory
sh "curl -u username:password -T target/your-project-name.jar https://your-artifactory-url/your-repo-name/your-project-name.jar"
}
}
}
stage('CD - Deploy to OpenShift') {
steps {
script {
// Pull the JAR from Artifactory and deploy using YAML
sh "curl -u username:password -O https://your-artifactory-url/your-repo-name/your-project-name.jar"
sh 'oc apply -f deployment.yaml'
}
}
}
stage('Send Email with Logs') {
steps {
script {
// Attach logs and send email
def logFile = 'build.log'
sh "cat ${logFile}" // Assuming logs are captured in build.log
emailext(
subject: "Build Logs for ${env.BUILD_NUMBER}",
body: "Please find the attached logs for build #${env.BUILD_NUMBER}",
attachLog: true,
attachments: "${logFile}"
)
}
}
}
}
post {
always {
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
junit 'target/surefire-reports/*.xml'
}
}
}