-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.semantic
69 lines (62 loc) · 2.65 KB
/
Jenkinsfile.semantic
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
69
def releaseTag
pipeline {
agent any
stages {
stage('Checkout') {
steps {
script {
checkout([
$class: 'GitSCM',
branches: [[name: 'main']],
userRemoteConfigs: [[credentialsId: 'github_token', url: 'https://github.com/cyse7125-su24-team04/cve-operator.git']]
])
}
}
}
stage('Release CVE-App') {
steps {
script {
withCredentials([usernamePassword(credentialsId: 'github_token', usernameVariable: 'GH_USERNAME', passwordVariable: 'GH_TOKEN')]) {
sh 'npm install @semantic-release/commit-analyzer'
sh 'npm install @semantic-release/release-notes-generator'
sh 'npm install @semantic-release/changelog'
sh 'npm install @semantic-release/npm'
sh 'npm install @semantic-release/git'
sh 'npm install @semantic-release/github'
sh 'npm install semantic-release-helm'
sh 'npx semantic-release'
}
}
}
}
stage('Setup Docker Buildx') {
steps {
script {
// Delete existing buildx instance if it exists
sh 'docker buildx rm mybuilder || true'
// Set up Docker Buildx
sh 'docker buildx create --name mybuilder --use'
sh 'docker buildx inspect --bootstrap'
}
}
}
stage('Build Multi-platform Docker Image') {
steps {
script {
releaseTag = sh(returnStdout: true, script: 'git describe --tags --abbrev=0').trim()
echo "Release tag is ${releaseTag}"
withCredentials([usernamePassword(credentialsId: 'dockerhub_credentials', usernameVariable: 'DOCKERHUB_USERNAME', passwordVariable: 'DOCKERHUB_PASSWORD')]) {
sh "echo \$DOCKERHUB_PASSWORD | docker login -u \$DOCKERHUB_USERNAME --password-stdin"
}
// Build multi-platform Docker image
sh """
docker buildx build --platform linux/amd64,linux/arm64 \
-t vamsidharp/webapp-cve:${releaseTag} \
-t vamsidharp/webapp-cve:latest \
--push .
"""
}
}
}
}
}