Skip to content

Commit f7393e9

Browse files
author
Donald Morton
committed
Add binaries to Github Releases page
1 parent f7b871a commit f7393e9

File tree

1 file changed

+42
-8
lines changed

1 file changed

+42
-8
lines changed

jenkins.groovy

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,65 @@
1-
pipeline
1+
pipeline
22
{
33
agent { label 'linux' }
4-
4+
5+
options
6+
{
7+
buildDiscarder logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '100', daysToKeepStr: '30', numToKeepStr: '100')
8+
timestamps()
9+
}
10+
511
tools
612
{
713
go 'Go'
814
}
9-
10-
stages
15+
16+
stages
1117
{
12-
stage('Build')
18+
stage('Build')
1319
{
1420
steps {
1521
git 'https://github.com/Graylog2/graylog-project-cli.git'
1622

1723
sh "make"
1824
}
1925

20-
post
26+
post
2127
{
22-
success
28+
success
2329
{
2430
archiveArtifacts '*.linux'
2531
archiveArtifacts '*.darwin'
2632
}
2733
}
2834
}
35+
36+
stage('Release')
37+
{
38+
39+
when
40+
{
41+
buildingTag()
42+
}
43+
44+
environment
45+
{
46+
GITHUB_CREDS = credentials('github-access-token')
47+
}
48+
49+
steps
50+
{
51+
echo "Releasing ${TAG_NAME} to Github..."
52+
53+
script
54+
{
55+
def RELEASE_DATA = sh returnStdout: true, script: "curl -s --user \"$GITHUB_CREDS\" -X POST --data \'{ \"tag_name\": \"${TAG_NAME}\", \"name\": \"v${TAG_NAME}\", \"body\": \"Insert features here.\", \"draft\": true }\' https://api.github.com/repos/Graylog2/graylog-project-cli/releases"
56+
def props = readJSON text: RELEASE_DATA
57+
env.RELEASE_ID = props.id
58+
59+
sh 'curl -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'
60+
sh 'curl -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.darwin'
61+
}
62+
}
63+
}
2964
}
3065
}
31-

0 commit comments

Comments
 (0)