forked from Saurabh-pec/Calculator-javaProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
44 lines (40 loc) · 1.62 KB
/
Jenkinsfile
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
pipeline {
agent { label 'macHost' }
environment {
BUILD_ATTESTATION_FILE = 'build-attestation.json'
TEST_ATTESTATION_FILE = 'test-attestation.json'
ARCHIVISTA_URL = 'http://localhost:8082/v1/upload' // Adjusted to the correct API endpoint
}
stages {
stage('Preparation') {
steps {
script {
if (sh(script: 'which witness && which curl', returnStatus: true) != 0) {
error "Required tools are not installed or not in PATH"
}
}
}
}
stage('Build') {
steps {
sh 'mvn clean package'
sh "witness run --step build -o ${env.BUILD_ATTESTATION_FILE} -- mvn clean package"
script {
// Using 'curl' to POST the attestation JSON file to Archivista
def result = sh(script: "curl -X POST -H 'Content-Type: application/json' --data-binary @${env.BUILD_ATTESTATION_FILE} ${env.ARCHIVISTA_URL}", returnStdout: true)
echo "Upload response: ${result}"
}
}
}
stage('Test') {
steps {
sh 'mvn test'
sh "witness run --step test -o ${env.TEST_ATTESTATION_FILE} -- mvn test"
script {
def result = sh(script: "curl -X POST -H 'Content-Type: application/json' --data-binary @${env.TEST_ATTESTATION_FILE} ${env.ARCHIVISTA_URL}", returnStdout: true)
echo "Upload response: ${result}"
}
}
}
}
}