forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(jenkinsfile): add docker image publish job for git tag (ethereu…
…m#198) * add tag jenkinsfile * fix * msg change * change * fix * change * trigger * more precise * simplify Co-authored-by: vincent <419436363@qq.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
- Loading branch information
1 parent
2891916
commit cdaea93
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
credentialDocker = 'dockerhub' | ||
|
||
pipeline { | ||
agent any | ||
options { | ||
timeout (20) | ||
} | ||
tools { | ||
go 'go-1.18' | ||
nodejs "nodejs" | ||
} | ||
environment { | ||
GO111MODULE = 'on' | ||
PATH="/home/ubuntu/.cargo/bin:$PATH" | ||
// LOG_DOCKER = 'true' | ||
} | ||
stages { | ||
stage('Tag') { | ||
steps { | ||
script { | ||
TAGNAME = sh(returnStdout: true, script: 'git tag -l --points-at HEAD') | ||
sh "echo ${TAGNAME}" | ||
// ... | ||
} | ||
} | ||
} | ||
stage('Build') { | ||
environment { | ||
DOCKER_CREDENTIALS = credentials('dockerhub') | ||
} | ||
steps { | ||
withCredentials([usernamePassword(credentialsId: "${credentialDocker}", passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { | ||
// Use a scripted pipeline. | ||
script { | ||
stage('Push image') { | ||
if (TAGNAME == ""){ | ||
return; | ||
} | ||
sh "docker login --username=${dockerUser} --password=${dockerPassword}" | ||
sh "docker build -t scrolltech/l2geth:${TAGNAME} ." | ||
sh "docker push scrolltech/l2geth:${TAGNAME}" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
success { | ||
slackSend(message: "l2geth tag ${TAGNAME} build dockersSuccessed") | ||
} | ||
// triggered when red sign | ||
failure { | ||
slackSend(message: "l2geth tag ${TAGNAME} build docker failed") | ||
} | ||
always { | ||
cleanWs() | ||
} | ||
} | ||
} |