Skip to content

Commit

Permalink
build(jenkinsfile): add docker image publish job for git tag (ethereu…
Browse files Browse the repository at this point in the history
…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
3 people authored Jan 13, 2023
1 parent 2891916 commit cdaea93
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions push-docker-tag.Jenkinsfile
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()
}
}
}

0 comments on commit cdaea93

Please sign in to comment.