@@ -71,22 +71,23 @@ pipeline {
7171 }
7272 }
7373 }
74+ stage(' Snapshot' ) {
75+ options { skipDefaultCheckout() }
76+ when { not { tag pattern : ' .*' , comparator : ' REGEXP' } }
77+ steps {
78+ goReleaser() {
79+ sh(label : ' goreleaser --snapshot' , script : ' goreleaser release --snapshot' )
80+ }
81+ }
82+ }
7483 stage(' Release' ) {
7584 options { skipDefaultCheckout() }
7685 when { tag pattern : ' v\\ d+\\ .\\ d+\\ .\\ d+.*' , comparator : ' REGEXP' }
7786 steps {
78- deleteDir()
79- unstash ' source'
80- dir(" ${ BASE_DIR} " ){
81- dockerLogin(secret : " ${ DOCKER_ELASTIC_SECRET} " , registry : " ${ DOCKER_REGISTRY} " )
82- withGoEnv() {
83- sh(
label :
' install goreleaser' ,
script :
' go install github.com/goreleaser/[email protected] ' )
84- withCredentials([string(credentialsId : " ${ env.GITHUB_TOKEN_CREDENTIALS} " , variable : ' GITHUB_TOKEN' )]) {
85- // Ensure that tags are present so goreleaser can build the changelog from the last release.
86- gitCmd(cmd : ' fetch' , args : ' --unshallow --tags' )
87- sh(label : ' goreleaser' , script : ' goreleaser release' )
88- }
89- }
87+ goReleaser() {
88+ // Ensure that tags are present so goreleaser can build the changelog from the last release.
89+ gitCmd(cmd : ' fetch' , args : ' --unshallow --tags' )
90+ sh(label : ' goreleaser release' , script : ' goreleaser release' )
9091 }
9192 }
9293 post {
@@ -115,3 +116,18 @@ def notifyStatus(def args = [:]) {
115116 subject : args. subject,
116117 body : args. body)
117118}
119+
120+
121+ def goReleaser (Closure body ) {
122+ deleteDir()
123+ unstash ' source'
124+ dir(" ${ BASE_DIR} " ){
125+ dockerLogin(secret : " ${ DOCKER_ELASTIC_SECRET} " , registry : " ${ DOCKER_REGISTRY} " )
126+ withGoEnv() {
127+ sh(
label :
' install goreleaser' ,
script :
' go install github.com/goreleaser/[email protected] ' )
128+ withCredentials([string(credentialsId : " ${ env.GITHUB_TOKEN_CREDENTIALS} " , variable : ' GITHUB_TOKEN' )]) {
129+ body()
130+ }
131+ }
132+ }
133+ }
0 commit comments