2 Star 0 Fork 2

Thoughtworks/fabric-ca

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Jenkinsfile 3.08 KB
一键复制 编辑 原始数据 按行查看 历史
Yi Weili 提交于 2021-02-18 14:11 . (chore) CI push image to dockerhub
def getRepoURL() {
sh "git config --get remote.origin.url > .git/remote-url"
return readFile(".git/remote-url").trim()
}
def projectName = "hyperledger/fabric-ca"
void setBuildStatus(String message, String state) {
repoUrl = getRepoURL()
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: repoUrl],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
]);
}
pipeline {
agent any
environment {
DOCKER_NS = "twblockchain"
EXTRA_VERSION = "build-${BUILD_NUMBER}"
GOPATH = "${WORKSPACE}/gopath"
}
stages {
stage('Build Image') {
steps {
setBuildStatus("Build Started", "PENDING");
dir("gopath/src/github.com/$projectName") {
checkout scm
sh '''
make clean docker
'''
}
}
}
stage('Upload Image') {
steps {
dir("gopath/src/github.com/$projectName") {
sh '''
make docker-list 2>/dev/null | grep "$DOCKER_NS" | while read line
do
docker tag $line ${line/:*/:latest}
docker push $line
docker push ${line/:*/:latest}
docker rmi $line
docker rmi ${line/:*/:latest}
done
'''
}
}
}
stage('Test Fabcar') {
steps {
dir("gopath/src/github.com/$projectName") {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
script {
def result = build(
job: 'fabric-samples',
propagate: false,
parameters: [
[$class: 'StringParameterValue', name: 'BYFN_CA', value: 'yes'],
[$class: 'StringParameterValue', name: 'IMAGE_CA', value: sh(script: 'make fabric-ca-docker-list 2>/dev/null ', returnStdout: true).trim()],
]
)
if (result.result.equals("SUCCESS")) {
echo "Passed Test Fabcar"
} else {
error "Failed Test Fabcar"
}
}
}
}
}
}
}
post {
success {
setBuildStatus("Build succeeded", "SUCCESS");
}
unsuccessful {
setBuildStatus("Build failed", "FAILURE");
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/thoughtworks/fabric-ca.git
git@gitee.com:thoughtworks/fabric-ca.git
thoughtworks
fabric-ca
fabric-ca
release-1.4-gm

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385