-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathJenkinsfile
142 lines (131 loc) · 5.21 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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
pipeline {
agent any
environment {
NPM_CONFIG_CACHE = "${WORKSPACE}/.npm"
}
stages {
stage('Build') {
agent {
docker {
image 'maven:3-openjdk-11'
reuseNode true
}
}
steps {
sh 'set'
// Run Maven on a Unix agent.
sh 'mvn -Dmaven.test.failure.ignore=true clean package -DversionHash=$(git rev-parse --short HEAD)'
sh "cp target/a2lparser-*-jar-with-dependencies.jar a2lparser.jar"
sh "java -jar a2lparser.jar -jsc -o a2lSchema.json"
sh "java -jar a2lparser.jar -a2l src/test/resources/freeTest.a2l -c ISO-8859-1 -mj -o freeTestA2l.minified.json"
}
post {
// If Maven was able to run the tests, even if some of the test
// failed, record the test results and archive the jar file.
success {
junit '**/target/surefire-reports/TEST-*.xml'
archiveArtifacts 'target/*.jar'
archiveArtifacts 'a2lSchema.json'
}
}
}
stage('C# codegen') {
agent {
docker {
image 'mcr.microsoft.com/dotnet/sdk:6.0-alpine'
reuseNode true
}
}
environment {
HOME = '/tmp'
}
steps {
dir("codegen_csharp") {
sh "dotnet run --project A2lParserCodeGenerator.csproj ../a2lSchema.json"
sh "dotnet run --project A2lParserSample.csproj ../freeTestA2l.minified.json"
}
}
post {
success {
archiveArtifacts 'codegen_csharp/A2l.cs'
}
}
}
stage('Python codegen') {
agent {
docker {
image 'python:3.11-slim'
args '-u root'
reuseNode true
}
}
steps {
dir("codegen_python") {
sh "pip3 install -r requirements.txt"
sh "python3 generatePythonCode.py ../a2lSchema.json"
sh "python3 sample.py ../freeTestA2l.minified.json"
}
}
post {
success {
archiveArtifacts 'codegen_python/a2l.py'
}
}
}
stage('Typescript codegen') {
agent {
docker {
image 'node:lts-alpine'
args '-u root'
reuseNode true
}
}
steps {
sh "apk add g++ make py3-pip"
dir("codegen_typescript") {
sh "npm install"
// expect it to fail
sh "npx tsc || true"
sh "node ./dist/codegen.js ../a2lSchema.json"
sh "npx tsc"
sh "node ./dist/sample.js ../freeTestA2l.minified.json"
}
}
post {
success {
archiveArtifacts 'codegen_typescript/src/a2l.d.ts'
}
}
}
stage('Publish release') {
when {
expression { env.TAG_NAME && env.TAG_NAME.toString().startsWith("v") }
}
agent {
docker {
image 'golang:latest'
args '-u root'
reuseNode true
}
}
steps {
withCredentials([usernamePassword(credentialsId: 'GithubJenkinsToken', usernameVariable:'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN')]) {
sh 'go install github.com/github-release/github-release@latest'
sh 'export GITHUB_ORGANIZATION=Luncher91'
sh 'export GITHUB_REPO=A2LParser'
sh 'export VERSION_NAME=${TAG_NAME:1}'
sh 'echo "Deleting release from github before creating new one"'
sh 'github-release delete --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${TAG_NAME}'
sh 'echo "Creating a new release in github"'
sh 'github-release release --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${TAG_NAME} --name "${VERSION_NAME}"'
sh 'echo "Uploading the artifacts into github"'
sh 'github-release upload --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${TAG_NAME} --file a2lSchema.json'
sh 'github-release upload --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${TAG_NAME} --file target/*.jar'
sh 'github-release upload --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${TAG_NAME} --file codegen_csharp/A2l.cs'
sh 'github-release upload --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${TAG_NAME} --file codegen_python/a2l.py'
sh 'github-release upload --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${TAG_NAME} --file codegen_typescript/src/a2l.d.ts'
}
}
}
}
}