Skip to content

Commit e50991a

Browse files
authored
release: provide docker images (#123)
1 parent 23a14e7 commit e50991a

File tree

3 files changed

+45
-13
lines changed

3 files changed

+45
-13
lines changed

.ci/Jenkinsfile

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

.goreleaser.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,15 @@ builds:
55
ldflags:
66
- -X github.com/elastic/elastic-agent-changelog-tool/internal/version.CommitHash={{.ShortCommit}}
77
- -X github.com/elastic/elastic-agent-changelog-tool/internal/version.SourceDateEpoch={{.CommitDate}}
8-
- -X github.com/elastic/elastic-agent-changelog-tool/internal/version.Tag={{.Tag}}
8+
- -X github.com/elastic/elastic-agent-changelog-tool/internal/version.Tag={{.Tag}}
9+
dockers:
10+
- image_templates:
11+
- "docker.elastic.co/observability-ci/{{.ProjectName}}"
12+
- "docker.elastic.co/observability-ci/{{.ProjectName}}:{{ .Tag }}"
13+
skip_push: false
14+
build_flag_templates:
15+
- "--pull"
16+
- "--label=org.opencontainers.image.created={{.Date}}"
17+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
18+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
19+
- "--label=org.opencontainers.image.version={{.Version}}"

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM docker.io/library/alpine:3.15.6
2+
3+
COPY elastic-agent-changelog-tool /usr/bin/elastic-agent-changelog-tool
4+
5+
ENTRYPOINT ["/usr/bin/elastic-agent-changelog-tool"]

0 commit comments

Comments
 (0)