-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
138 lines (123 loc) · 4.84 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
#!/usr/bin/env groovy
// Generated from snippet generator 'properties; set job properties'
// Keep only the most recent XX builds
properties([buildDiscarder(logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '',
numToKeepStr: '10')),
disableConcurrentBuilds(),
[$class: 'CopyArtifactPermissionProperty', projectNames: '*']
])
node ('rocmtest')
{
// Convenience variables for common paths used in building
def workspace_dir_abs = pwd()
def build_dir_debug_rel = "build/debug"
def build_dir_release_rel = "build/release"
def build_dir_cmake_tests_rel = "build/cmake-tests"
def build_dir_debug_abs = "${workspace_dir_abs}/${build_dir_debug_rel}"
def build_dir_release_abs = "${workspace_dir_abs}/${build_dir_release_rel}"
def build_dir_cmake_tests_abs = "${workspace_dir_abs}/${build_dir_cmake_tests_rel}"
// The client workspace is shared with the docker container
stage('HCC Checkout')
{
deleteDir( )
checkout scm
// list the commit hash of the submodules
sh 'git ls-tree HEAD | grep commit'
// clone the submodules
sh 'git submodule update --init'
}
def hcc_build_image = null
stage('ubuntu-16.04 image')
{
def build_org = "hcc-lc"
def build_type_name = "build-ubuntu-16.04"
def dockerfile_name = "dockerfile-${build_type_name}"
def build_image_name = "${build_type_name}"
dir('docker')
{
hcc_build_image = docker.build( "${build_org}/${build_image_name}:latest", "-f ${dockerfile_name} --build-arg build_type=Release --build-arg rocm_install_path=/opt/rocm ." )
}
}
// JENKINS-33510: the jenkinsfile dir() command is not workin well with docker.inside()
hcc_build_image.inside( '--device=/dev/kfd' )
{
stage('hcc-lc release')
{
// Build release hcc
def build_config = "Release"
def hcc_install_prefix = "/opt/rocm"
// cmake -B${build_dir_release_abs} specifies to cmake where to generate build files
// This is necessary because cmake seemingly randomly generates build makefile into the docker
// workspace instead of the current set directory. Not sure why, but it seems like a bug
sh """
mkdir -p ${build_dir_release_rel}
cd ${build_dir_release_rel}
cmake -B${build_dir_release_abs} \
-DCMAKE_INSTALL_PREFIX=${hcc_install_prefix} \
-DCPACK_SET_DESTDIR=OFF \
-DCMAKE_BUILD_TYPE=${build_config} \
-DHSA_AMDGPU_GPU_TARGET="gfx701;gfx803" \
../..
make -j\$(nproc)
"""
// Cap the maximum amount of testing, in case of hangs
timeout(time: 1, unit: 'HOURS')
{
stage("unit testing")
{
// install from debian packages because pre/post scripts set up softlinks install targets don't
sh """#!/usr/bin/env bash
cd ${build_dir_release_abs}
make install
mkdir -p ${build_dir_cmake_tests_abs}
cd ${build_dir_cmake_tests_abs}
CXX=${hcc_install_prefix}/bin/hcc cmake ${workspace_dir_abs}/cmake-tests
make
./cmake-test
"""
// junit "${build_dir_release_abs}/*.xml"
}
}
stage("packaging")
{
sh "cd ${build_dir_release_abs}; make package"
archiveArtifacts artifacts: "${build_dir_release_rel}/*.deb", fingerprint: true
// archiveArtifacts artifacts: "${build_dir_release_rel}/*.rpm", fingerprint: true
}
}
}
// Everything above builds hcc in a clean container to create a debain package
// Create a clean docker image that installs the debian package
def hcc_install_image = null
stage('artifactory')
{
def artifactory_org = "${env.JOB_NAME}".toLowerCase()
def image_name = "hcc-lc-ubuntu-16.04"
dir("${build_dir_release_abs}/docker")
{
// We copy the docker files into the bin directory where the .deb lives so that it's a clean
// build everytime
sh "cp -r ${workspace_dir_abs}/docker/* .; cp ${build_dir_release_abs}/*.deb ."
hcc_install_image = docker.build( "${artifactory_org}/${image_name}:${env.BUILD_NUMBER}", "-f dockerfile-${image_name} ." )
}
// The connection to artifactory can fail sometimes, but this should not be treated as a build fail
try
{
docker.withRegistry('http://compute-artifactory:5001', 'artifactory-cred' )
{
hcc_install_image.push( "${env.BUILD_NUMBER}" )
hcc_install_image.push( 'latest' )
}
}
catch( err )
{
currentBuild.result = 'SUCCESS'
}
// Lots of images with tags are created above; no apparent way to delete images:tags with docker global variable
// run bash script to clean images:tags after successful pushing
sh "docker images | grep \"${artifactory_org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi"
}
}