-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline_script.groovy
58 lines (43 loc) · 1.11 KB
/
pipeline_script.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
@Library('shared-library') _
pipeline {
agent any
parameters {
string defaultValue: 'master', name: 'Branch', trim: true
}
environment {
Build_by = "Bazel"
}
stages {
stage('Build') {
steps {
echo 'git checkout from ' + params.Branch
git branch: 'main', credentialsId: 'd9feb0df-0fb1-4589-ab8e-aaecb3295d6e', url: 'https://github.com/bazelbuild/examples.git'
script {
if (env.Build_by == 'Bazel') {
bazel_helper.prepare_environment()
echo "Building project using Bazel "
bazel_helper.create_build(build_path: 'cpp-tutorial/stage1',
build_function: 'hello-world')
} else {
echo "This build system is not configured"
}
}
}
}
stage('test') {
steps {
script{
def ret = sh(script: ''' cd cpp-tutorial/stage1/bazel-bin/main
./hello-world ''', returnStdout: true)
echo ret.trim()
assert ret.trim() == 'Hello world'
}
}
}
}
post {
always {
deleteDir()
}
}
}