Commit bd8aeecd authored by mdj33's avatar mdj33 Committed by vipwzw

add jenkins auto-ci

parent eacf28fd
......@@ -27,6 +27,7 @@ jobs:
- make test
- stage: coverage
if: branch = master
go: "1.9.x"
before_install:
- go get -t -v ./...
......@@ -35,8 +36,7 @@ jobs:
- make coverage
after_success:
- bash <(curl -s https://codecov.io/bash)
branches:
only: master
- stage: deploy
sudo: required
......
// ci server: http://39.98.41.13:8080
// user/pass: jenkins/33fuzamei123
pipeline {
agent any
......@@ -14,7 +12,7 @@ pipeline {
retry(1)
timestamps()
gitLabConnection('gitlab33')
gitlabBuilds(builds: ['check', 'build', 'test', 'deploy'])
gitlabBuilds(builds: ['check'])
checkoutToSubdirectory "src/github.com/33cn/plugin"
}
......@@ -23,64 +21,13 @@ pipeline {
steps {
dir("${PROJ_DIR}"){
gitlabCommitStatus(name: 'check'){
sh "git branch;git status"
sh "make auto_ci branch=${env.gitlabSourceBranch}"
sh "git branch"
sh "make auto_ci branch=${env.ghprbSourceBranch} originx=${env.ghprbAuthorRepoGitUrl}"
}
}
}
}
stage('build') {
steps {
dir("${env.PROJ_DIR}"){
gitlabCommitStatus(name: 'build'){
sh 'make checkgofmt'
sh 'make linter'
}
}
}
}
stage('test'){
agent {
docker{
image 'suyanlong/chain33-run:latest'
}
}
environment {
GOPATH = "${WORKSPACE}"
PROJ_DIR = "${WORKSPACE}/src/github.com/33cn/plugin"
}
steps {
dir("${env.PROJ_DIR}"){
gitlabCommitStatus(name: 'test'){
sh 'make test'
//sh 'export CC=clang-5.0 && make msan'
}
}
}
}
stage('deploy') {
steps {
dir("${PROJ_DIR}"){
gitlabCommitStatus(name: 'deploy'){
sh 'make build_ci'
sh "cd build && mkdir ${env.BUILD_NUMBER} && cp ci/* ${env.BUILD_NUMBER} -r && cp chain33* Dockerfile* docker* *.sh ${env.BUILD_NUMBER}/ && cd ${env.BUILD_NUMBER}/ && ./docker-compose-pre.sh run ${env.BUILD_NUMBER} all "
}
}
}
post {
always {
dir("${PROJ_DIR}"){
sh "cd build/${env.BUILD_NUMBER} && ./docker-compose-pre.sh down ${env.BUILD_NUMBER} all && cd .. && rm -rf ${env.BUILD_NUMBER} && cd .. && make clean "
}
}
}
}
}
post {
......@@ -92,16 +39,16 @@ pipeline {
success {
echo 'I succeeeded!'
echo "email user: ${gitlabUserEmail}"
mail to: "${gitlabUserEmail}",
echo "email user: ${ghprbActualCommitAuthorEmail}"
mail to: "${ghprbActualCommitAuthorEmail}",
subject: "Successed Pipeline: ${currentBuild.fullDisplayName}",
body: "this is success with ${env.BUILD_URL}"
}
failure {
echo 'I failed '
echo "email user: ${gitlabUserEmail}"
mail to: "${gitlabUserEmail}",
echo "email user: ${ghprbActualCommitAuthorEmail}"
mail to: "${ghprbActualCommitAuthorEmail}",
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}
......
pipeline {
agent any
environment {
GOPATH = "${WORKSPACE}"
PROJ_DIR = "${WORKSPACE}/src/github.com/33cn/plugin"
}
options {
timeout(time: 2,unit: 'HOURS')
retry(1)
timestamps()
gitLabConnection('gitlab33')
gitlabBuilds(builds: ['check', 'build', 'test', 'deploy'])
checkoutToSubdirectory "src/github.com/33cn/plugin"
}
stages {
stage('check') {
steps {
dir("${PROJ_DIR}"){
gitlabCommitStatus(name: 'check'){
sh "git branch;git status"
sh "make auto_ci branch=${env.gitlabSourceBranch}"
}
}
}
}
stage('build') {
steps {
dir("${env.PROJ_DIR}"){
gitlabCommitStatus(name: 'build'){
sh 'make checkgofmt'
sh 'make linter'
}
}
}
}
stage('test'){
agent {
docker{
image 'suyanlong/chain33-run:latest'
}
}
environment {
GOPATH = "${WORKSPACE}"
PROJ_DIR = "${WORKSPACE}/src/github.com/33cn/plugin"
}
steps {
dir("${env.PROJ_DIR}"){
gitlabCommitStatus(name: 'test'){
sh 'make test'
//sh 'export CC=clang-5.0 && make msan'
}
}
}
}
stage('deploy') {
steps {
dir("${PROJ_DIR}"){
gitlabCommitStatus(name: 'deploy'){
sh 'make build_ci'
sh "cd build && mkdir ${env.BUILD_NUMBER} && cp ci/* ${env.BUILD_NUMBER} -r && cp chain33* Dockerfile* docker* *.sh ${env.BUILD_NUMBER}/ && cd ${env.BUILD_NUMBER}/ && ./docker-compose-pre.sh run ${env.BUILD_NUMBER} all "
}
}
}
post {
always {
dir("${PROJ_DIR}"){
sh "cd build/${env.BUILD_NUMBER} && ./docker-compose-pre.sh down ${env.BUILD_NUMBER} all && cd .. && rm -rf ${env.BUILD_NUMBER} && cd .. && make clean "
}
}
}
}
}
post {
always {
echo 'One way or another, I have finished'
// clean up our workspace
deleteDir()
}
success {
echo 'I succeeeded!'
echo "email user: ${gitlabUserEmail}"
mail to: "${gitlabUserEmail}",
subject: "Successed Pipeline: ${currentBuild.fullDisplayName}",
body: "this is success with ${env.BUILD_URL}"
}
failure {
echo 'I failed '
echo "email user: ${gitlabUserEmail}"
mail to: "${gitlabUserEmail}",
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}
}
}
......@@ -224,7 +224,10 @@ auto_ci: clean fmt_proto fmt_shell protobuf
git add -u; \
git status; \
git commit -a -m "auto ci"; \
git push origin HEAD:$(branch); \
git remote add originx $(originx); \
git remote -v; \
git push --quiet --set-upstream originx HEAD:$(branch); \
git log -n 2; \
exit 1; \
fi;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment