|
1 | 1 | pipeline
|
2 | 2 | {
|
3 |
| - agent none |
4 |
| - |
5 |
| - options |
6 |
| - { |
7 |
| - buildDiscarder logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '10', daysToKeepStr: '30', numToKeepStr: '10') |
8 |
| - timestamps() |
9 |
| - withAWS(region:'eu-west-1', credentials:'aws-key-releases') |
10 |
| - } |
11 |
| - |
12 |
| - tools |
13 |
| - { |
14 |
| - go 'Go 1.19' |
15 |
| - } |
16 |
| - |
17 |
| - environment |
18 |
| - { |
19 |
| - GOPATH = '/home/jenkins/go' |
20 |
| - GO15VENDOREXPERIMENT=1 |
21 |
| - } |
22 |
| - |
23 |
| - stages |
24 |
| - { |
25 |
| - stage('Build') |
| 3 | + agent none |
| 4 | + |
| 5 | + options |
| 6 | + { |
| 7 | + buildDiscarder logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '10', daysToKeepStr: '30', numToKeepStr: '10') |
| 8 | + timestamps() |
| 9 | + withAWS(region:'eu-west-1', credentials:'aws-key-releases') |
| 10 | + } |
| 11 | + |
| 12 | + tools |
| 13 | + { |
| 14 | + go 'Go 1.19' |
| 15 | + } |
| 16 | + |
| 17 | + environment |
| 18 | + { |
| 19 | + GOPATH = '/home/jenkins/go' |
| 20 | + GO15VENDOREXPERIMENT=1 |
| 21 | + CHOCO_API_KEY = credentials('chocolatey-api-key') |
| 22 | + } |
| 23 | + |
| 24 | + stages |
| 25 | + { |
| 26 | + stage('Build') |
| 27 | + { |
| 28 | + agent |
26 | 29 | {
|
27 |
| - agent |
28 |
| - { |
29 |
| - label 'linux' |
30 |
| - } |
| 30 | + // Select the node for all nested stages. |
| 31 | + label 'linux' |
| 32 | + } |
| 33 | + |
| 34 | + // All nested stages run on the same node because the nested stages |
| 35 | + // don't have an agent label selector. |
| 36 | + // That ensures we share the workspace between the different stages. |
| 37 | + stages |
| 38 | + { |
| 39 | + stage('Compile') |
| 40 | + { |
31 | 41 | steps
|
32 | 42 | {
|
33 |
| - sh 'go version' |
34 |
| - sh 'go mod vendor' |
35 |
| - sh "make test" |
36 |
| - sh 'make build-all' |
37 |
| - stash name: 'build artifacts', includes: 'build/**' |
| 43 | + sh 'go version' |
| 44 | + sh 'go mod vendor' |
| 45 | + sh "make test" |
| 46 | + sh 'make build-all' |
38 | 47 | }
|
| 48 | + } |
39 | 49 |
|
40 |
| - post |
| 50 | + stage('Package') |
| 51 | + { |
| 52 | + agent |
41 | 53 | {
|
42 |
| - cleanup |
| 54 | + docker |
43 | 55 | {
|
44 |
| - cleanWs() |
| 56 | + image 'torch/jenkins-fpm-cook:latest' |
| 57 | + args '-u jenkins:docker' |
| 58 | + reuseNode true |
45 | 59 | }
|
46 | 60 | }
|
47 |
| - } |
48 | 61 |
|
49 |
| - stage('Package') |
50 |
| - { |
51 |
| - agent |
52 |
| - { |
53 |
| - docker |
54 |
| - { |
55 |
| - label 'linux' |
56 |
| - image 'torch/jenkins-fpm-cook:latest' |
57 |
| - args '-u jenkins:docker' |
58 |
| - } |
59 |
| - } |
60 |
| - |
61 |
| - steps |
62 |
| - { |
63 |
| - unstash 'build artifacts' |
| 62 | + steps |
| 63 | + { |
64 | 64 | sh 'make package-all'
|
| 65 | + } |
| 66 | + } |
65 | 67 |
|
66 |
| - stash name: 'package artifacts', includes: 'dist/pkg/**' |
67 |
| - } |
68 |
| - |
69 |
| - post |
70 |
| - { |
71 |
| - success |
| 68 | + stage('Chocolatey Pack') |
| 69 | + { |
| 70 | + agent |
| 71 | + { |
| 72 | + dockerfile |
72 | 73 | {
|
73 |
| - archiveArtifacts 'dist/pkg/*' |
| 74 | + label 'linux' |
| 75 | + filename 'Dockerfile.chocolatey' |
| 76 | + dir 'docker' |
| 77 | + additionalBuildArgs '-t local/sidecar-chocolatey' |
| 78 | + reuseNode true |
74 | 79 | }
|
| 80 | + } |
| 81 | + |
| 82 | + steps |
| 83 | + { |
| 84 | + sh 'make package-chocolatey' |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + stage('Chocolatey Push') |
| 89 | + { |
| 90 | + when |
| 91 | + { |
| 92 | + buildingTag() |
| 93 | + } |
75 | 94 |
|
76 |
| - cleanup |
| 95 | + agent |
| 96 | + { |
| 97 | + dockerfile |
77 | 98 | {
|
78 |
| - cleanWs() |
| 99 | + label 'linux' |
| 100 | + filename 'Dockerfile.chocolatey' |
| 101 | + dir 'docker' |
| 102 | + additionalBuildArgs '-t local/sidecar-chocolatey' |
| 103 | + reuseNode true |
79 | 104 | }
|
80 |
| - } |
81 |
| - } |
| 105 | + } |
82 | 106 |
|
83 |
| - stage('Upload') |
84 |
| - { |
85 |
| - when |
86 |
| - { |
87 |
| - buildingTag() |
| 107 | + steps |
| 108 | + { |
| 109 | + sh 'make push-chocolatey' |
| 110 | + } |
88 | 111 | }
|
89 | 112 |
|
90 |
| - agent |
| 113 | + stage('Upload') |
91 | 114 | {
|
92 |
| - label 'linux' |
| 115 | + when |
| 116 | + { |
| 117 | + buildingTag() |
| 118 | + } |
| 119 | + |
| 120 | + steps |
| 121 | + { |
| 122 | + echo "==> Artifact checksums:" |
| 123 | + sh "sha256sum dist/pkg/*" |
| 124 | + |
| 125 | + s3Upload( |
| 126 | + workingDir: '.', |
| 127 | + bucket: 'graylog2-releases', |
| 128 | + path: "graylog-collector-sidecar/${env.TAG_NAME}/", |
| 129 | + file: "dist/pkg" |
| 130 | + ) |
| 131 | + } |
93 | 132 | }
|
| 133 | + } |
94 | 134 |
|
95 |
| - steps |
| 135 | + post |
| 136 | + { |
| 137 | + success |
96 | 138 | {
|
97 |
| - // Provide access to "dist/pkg", the previous cleanups removed the files |
98 |
| - unstash 'package artifacts' |
99 |
| - |
100 |
| - echo "==> Artifact checksums:" |
101 |
| - sh "sha256sum dist/pkg/*" |
102 |
| - |
103 |
| - s3Upload( |
104 |
| - workingDir: '.', |
105 |
| - bucket: 'graylog2-releases', |
106 |
| - path: "graylog-collector-sidecar/${env.TAG_NAME}/", |
107 |
| - file: "dist/pkg" |
108 |
| - ) |
| 139 | + archiveArtifacts 'dist/pkg/*' |
109 | 140 | }
|
110 | 141 |
|
111 |
| - post |
| 142 | + cleanup |
112 | 143 | {
|
113 |
| - cleanup |
114 |
| - { |
115 |
| - cleanWs() |
116 |
| - } |
| 144 | + cleanWs() |
117 | 145 | }
|
118 | 146 | }
|
119 |
| - } |
| 147 | + } |
| 148 | + } |
120 | 149 | }
|
0 commit comments