-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathjenkins.groovy
115 lines (96 loc) · 3.31 KB
/
jenkins.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
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
if (currentBuild.buildCauses.toString().contains('BranchIndexingCause'))
{
print "Build skipped due to trigger being Branch Indexing."
return
}
pipeline
{
agent { label 'linux' }
options
{
buildDiscarder logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '10', daysToKeepStr: '30', numToKeepStr: '10')
timestamps()
}
tools
{
go 'Go 1.23'
}
stages
{
stage('Build')
{
steps {
sh 'go version'
sh "make"
}
}
stage('Sign Windows Binaries')
{
when
{
buildingTag()
}
agent
{
docker
{
image 'graylog/internal-codesigntool:latest'
args '-u jenkins:jenkins'
registryCredentialsId 'docker-hub'
alwaysPull true
reuseNode true
}
}
environment
{
CODESIGN_USER = credentials('codesign-user')
CODESIGN_PASS = credentials('codesign-pass')
CODESIGN_TOTP_SECRET = credentials('codesign-totp-secret')
CODESIGN_CREDENTIAL_ID = credentials('codesign-credential-id')
}
steps
{
sh 'make sign-binaries'
}
}
stage('Release')
{
when
{
buildingTag()
}
environment
{
GITHUB_CREDS = credentials('github-access-token')
}
steps
{
echo "Releasing ${TAG_NAME} to Github..."
script
{
def RELEASE_DATA = sh returnStdout: true, script: "curl -fsSL --user \"$GITHUB_CREDS\" -X POST --data \'{ \"tag_name\": \"${TAG_NAME}\", \"name\": \"${TAG_NAME}\", \"body\": \"Insert features here.\", \"draft\": true }\' https://api.github.com/repos/Graylog2/graylog-project-cli/releases"
def props = readJSON text: RELEASE_DATA
env.RELEASE_ID = props.id
sh 'curl -fsSL -H "Authorization: token $GITHUB_CREDS" -H "Content-Type: application/octet-stream" --data-binary @graylog-project.linux https://uploads.github.com/repos/Graylog2/graylog-project-cli/releases/$RELEASE_ID/assets?name=graylog-project.linux'
sh 'curl -fsSL -H "Authorization: token $GITHUB_CREDS" -H "Content-Type: application/octet-stream" --data-binary @graylog-project.darwin-amd64 https://uploads.github.com/repos/Graylog2/graylog-project-cli/releases/$RELEASE_ID/assets?name=graylog-project.darwin-amd64'
sh 'curl -fsSL -H "Authorization: token $GITHUB_CREDS" -H "Content-Type: application/octet-stream" --data-binary @graylog-project.darwin-arm64 https://uploads.github.com/repos/Graylog2/graylog-project-cli/releases/$RELEASE_ID/assets?name=graylog-project.darwin-arm64'
sh 'curl -fsSL -H "Authorization: token $GITHUB_CREDS" -H "Content-Type: application/octet-stream" --data-binary @graylog-project.windows-amd64.exe https://uploads.github.com/repos/Graylog2/graylog-project-cli/releases/$RELEASE_ID/assets?name=graylog-project.windows-amd64.exe'
}
}
}
}
post
{
success
{
archiveArtifacts '*.linux'
archiveArtifacts '*.darwin-amd64'
archiveArtifacts '*.darwin-arm64'
archiveArtifacts '*.exe'
}
cleanup
{
cleanWs()
}
}
}