@@ -31,7 +31,10 @@ pipeline {
3131 steps {
3232 pipelineManager([ cancelPreviousRunningBuilds : [ when : ' PR' ] ])
3333 deleteDir()
34- gitCheckout(basedir : " ${ BASE_DIR} " , githubNotifyFirstTimeContributor : true )
34+ gitCheckout(basedir : " ${ BASE_DIR} " , githubNotifyFirstTimeContributor : true , shallow : false )
35+ dir(" ${ BASE_DIR} " ){
36+ sh(label : ' Fetch tags' , script : ' git fetch --prune --tags' )
37+ }
3538 stash allowEmpty : true , name : ' source' , useDefaultExcludes : false
3639 }
3740 }
@@ -50,6 +53,10 @@ pipeline {
5053 }
5154 }
5255 stage(' Parallel' ){
56+ when {
57+ not { buildingTag() }
58+ beforeAgent true
59+ }
5360 parallel {
5461 stage(' Linux' ) {
5562 options { skipDefaultCheckout() }
@@ -61,7 +68,6 @@ pipeline {
6168 deleteDir()
6269 unstash ' source'
6370 dir(" ${ BASE_DIR} " ){
64- sh script : ' git fetch --prune --tags' , label : ' build'
6571 dotnet(){
6672 sh script : ' ./build.sh release -c false' , label : ' build'
6773 }
@@ -73,7 +79,10 @@ pipeline {
7379 archiveArtifacts(allowEmptyArchive : true , artifacts : " ${ MSBUILDDEBUGPATH} /**/MSBuild_*.failure.txt" )
7480 }
7581 always {
76- junit(allowEmptyResults : true , keepLongStdio : true , testResults : " ${ BASE_DIR} /build/output/junit-*.xml" )
82+ dir(" ${ BASE_DIR} " ){
83+ junit(allowEmptyResults : true , keepLongStdio : true , testResults : ' build/output/junit-*.xml' )
84+ archiveArtifacts(allowEmptyArchive : true , artifacts : ' build/output/**/*' )
85+ }
7786 }
7887 }
7988 }
@@ -92,8 +101,7 @@ pipeline {
92101 withGithubNotify(context : ' Windows' ) {
93102 unstash ' source'
94103 dir(" ${ BASE_DIR} " ){
95- bat script : ' git fetch --prune --tags' , label : ' build'
96- bat script : ' choco install dotnetcore-sdk -m -y --no-progress -r --version 3.1.200' , label : ' Tools'
104+ bat script : ' choco install dotnetcore-sdk -m -y --no-progress -r --version 3.1.202' , label : ' Tools'
97105 bat script : ' build.bat release -c false' , label : ' build'
98106 }
99107 }
@@ -102,25 +110,70 @@ pipeline {
102110 unsuccessful {
103111 archiveArtifacts(allowEmptyArchive : true , artifacts : " ${ MSBUILDDEBUGPATH} /**/MSBuild_*.failure.txt" )
104112 }
113+ always {
114+ dir(" ${ BASE_DIR} " ){
115+ junit(allowEmptyResults : true , keepLongStdio : true , testResults : ' build/output/junit-*.xml' )
116+ archiveArtifacts(allowEmptyArchive : true , artifacts : ' build/output/**/*' )
117+ }
118+ }
105119 }
106120 }
107- stage(' Deploy' ) {
108- when {
109- branch ' master'
110- }
111- steps {
112- dir(" ${ BASE_DIR} " ){
113- release(' secret/apm-team/ci/elastic-observability-appveyor' )
114- }
121+ }
122+ }
123+ }
124+ }
125+ stage(' Release' ) {
126+ when {
127+ beforeAgent true
128+ anyOf {
129+ tag pattern : ' \\ d+\\ .\\ d+\\ .\\ d+(-(alpha|beta|rc)\\ d*)?' , comparator : ' REGEXP'
130+ branch ' master'
131+ }
132+ }
133+ stages {
134+ stage(' Generate' ) {
135+ steps {
136+ deleteDir()
137+ unstash ' source'
138+ dir(" ${ BASE_DIR} " ){
139+ dotnet() {
140+ sh(label : ' Generate local nuget packages' , script : ' ./build.sh generatepackages -s true' )
141+ sh(label : ' Validate *.npkg files that were created' , script : ' ./build.sh validatepackages -s true' )
142+ sh(label : ' Inspect public API change' , script : ' ./build.sh generateapichanges -s true' )
115143 }
116- post {
117- always {
118- archiveArtifacts(allowEmptyArchive : true , artifacts : " ${ BASE_DIR} /**/build/output/*.nupkg" )
144+ }
145+ }
146+ }
147+ stage(' Release to feedz.io' ) {
148+ when { branch ' master' }
149+ steps {
150+ dir(" ${ BASE_DIR} " ){
151+ deploy(secret : ' secret/apm-team/ci/elastic-observability-feedz.io' )
152+ }
153+ }
154+ }
155+ stage(' Release Notes' ) {
156+ when { buildingTag() }
157+ steps {
158+ dir(" ${ BASE_DIR} " ){
159+ withGitRelease(credentialsId : ' 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken' ) {
160+ dotnet() {
161+ sh(label : ' Generate release notes' , script : ' ./build.sh generatereleasenotes -s true' )
162+ sh(label : ' Inspect public API change' , script : ' ./build.sh generateapichanges -s true' )
163+ sh(label : ' Create or update release for tag on github' , script : " ./build.sh createreleaseongithub -s true --token ${ GITHUB_TOKEN} " )
119164 }
120165 }
121166 }
122167 }
123168 }
169+ stage(' Release to NuGet' ) {
170+ when { buildingTag() }
171+ steps {
172+ dir(" ${ BASE_DIR} " ){
173+ // deploy(secret: 'secret/apm-team/ci/elastic-observability-nuget')
174+ }
175+ }
176+ }
124177 }
125178 }
126179 }
@@ -133,15 +186,27 @@ pipeline {
133186
134187def dotnet (Closure body ){
135188 def dockerTagName = ' docker.elastic.co/observability-ci/ecs-dotnet-sdk-linux:latest'
136- sh label : ' Docker build' , script : " docker build --tag ${ dockerTagName} .ci/docker/sdk-linux"
189+ // When running in the CI with multiple parallel stages
190+ // the access could be considered as a DDOS attack.
191+ retryWithSleep(retries : 2 , seconds : 5 , backoff : true ) {
192+ sh label : ' Docker build' , script : " docker build --tag ${ dockerTagName} .ci/docker/sdk-linux"
193+ }
137194 docker. image(" ${ dockerTagName} " ). inside(" -e HOME='${ env.WORKSPACE} /${ env.BASE_DIR} '" ){
138195 body()
139196 }
140197}
141198
142- def release (secret ){
199+ def deploy (Map args = [:]) {
200+ def secret = args. secret
143201 def repo = getVaultSecret(secret : secret)
144- withEnvMask(vars : [[var : ' REPO_API_KEY' , password : repo. data. apiKey], [var : ' REPO_API_URL' , password : repo. data. url]]){
145- bat(label : ' Deploy' , script : " .ci/deploy.bat ${ REPO_API_KEY} ${ REPO_API_URL} " )
202+ withEnvMask(vars : [ [var : ' REPO_API_KEY' , password : repo. data. apiKey],
203+ [var : ' REPO_API_URL' , password : repo. data. url] ]) {
204+ if (isUnix()) {
205+ dotnet(){
206+ sh(label : ' Deploy' , script : " .ci/deploy.sh ${ REPO_API_KEY} ${ REPO_API_URL} " )
207+ }
208+ } else {
209+ bat(label : ' Deploy' , script : " .ci/deploy.bat ${ REPO_API_KEY} ${ REPO_API_URL} " )
210+ }
146211 }
147212}
0 commit comments