forked from marianob85/open_hardware_monitor-telegraf-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
70 lines (68 loc) · 1.66 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
properties(
[
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')),
]
)
pipeline
{
agent any
options {
skipDefaultCheckout true
}
environment {
GITHUB_TOKEN = credentials('marianob85-github-jenkins')
}
stages
{
stage('Build package')
{
agent{ label "linux/u18.04/go:1.15.13" }
steps
{
checkout scm
script {
env.GITHUB_REPO = sh(script: 'basename $(git remote get-url origin) .git', returnStdout: true).trim()
}
sh '''
make package
'''
archiveArtifacts artifacts: 'build/**', onlyIfSuccessful: true, fingerprint: true
stash includes: 'build/dist/**', name: 'dist'
}
}
stage('Test')
{
agent{ label "linux/u18.04/go:1.15.13" }
steps {
checkout scm
sh '''
make test
'''
}
}
stage('Release') {
when {
buildingTag()
}
agent{ label "linux/u18.04/go:1.15.13" }
steps {
unstash 'dist'
sh '''
export GOPATH=${PWD}
go get github.com/github-release/github-release
bin/github-release release --user marianob85 --repo ${GITHUB_REPO} --tag ${TAG_NAME} --name ${TAG_NAME}
for filename in build/dist/*; do
[ -e "$filename" ] || continue
basefilename=$(basename "$filename")
bin/github-release upload --user marianob85 --repo ${GITHUB_REPO} --tag ${TAG_NAME} --name ${basefilename} --file ${filename}
done
'''
}
}
}
post {
changed {
emailext body: "Please go to ${env.BUILD_URL}", to: '${DEFAULT_RECIPIENTS}', subject: "Job ${env.JOB_NAME} (${env.BUILD_NUMBER}) ${currentBuild.currentResult}".replaceAll("%2F", "/")
}
}
}