Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
L
logtransfer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢宇轩
logtransfer
Commits
470eedd7
Commit
470eedd7
authored
Jan 30, 2023
by
李世星
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(新增jenkinsfile文件): 202301301128
parent
e7279e39
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
274 additions
and
3 deletions
+274
-3
.gitignore
.gitignore
+1
-2
Jenkinsfile
Jenkinsfile
+244
-0
logtransfer-dev.conf
logtransfer-dev.conf
+12
-0
logtransfer-main.conf
logtransfer-main.conf
+12
-0
topic.go
source/topic.go
+5
-1
No files found.
.gitignore
View file @
470eedd7
/.idea
*.exe
/log
logtransfer
*.conf
\ No newline at end of file
logtransfer.conf
\ No newline at end of file
Jenkinsfile
0 → 100644
View file @
470eedd7
pipeline
{
options
{
gitLabConnection
(
'gitlab'
)
timeout
(
time:
12
,
unit:
'MINUTES'
)
}
agent
any
environment
{
CURRENT_JOB_NAME
=
sh
(
returnStdout:
true
,
script:
"echo ${JOB_BASE_NAME}-${BUILD_NUMBER}"
).
replaceAll
(
"\\s"
,
""
)
APP_GROUP
=
"logagent"
APP_NAME
=
"logtransfer"
}
parameters
{
choice
(
choices:
[
'Deploy'
,
'Rollback'
],
description:
'''Deploy:【发布】
Rollback:【回滚】'''
,
name:
'Deploy'
)
gitParameter
(
requiredParameter:
true
,
description:
'Version:【版本】'
,
name:
'DeployVersion'
,
selectedValue:
'TOP'
,
sortMode:
'DESCENDING_SMART'
,
type:
'PT_TAG'
)
}
triggers
{
GenericTrigger
(
// 构建时的标题
causeString:
'Triggered by $ref'
,
// 获取POST参数中的变量,key指的是变量名,通过$ref来访问对应的值,value指的是JSON匹配值(参考Jmeter的JSON提取器)
// ref指的是推送的分支,格式如:refs/heads/master
genericVariables:
[[
key:
'ref'
,
value:
'$.ref'
]],
// 打印获取的变量的key-value,此处会打印如:ref=refs/heads/master
printContributedVariables:
true
,
// 打印POST传递的参数
printPostContent:
true
,
// regexpFilterExpression与regexpFilterExpression成对使用
// 当两者相等时,会触发对应分支的构建
regexpFilterExpression:
'^refs/heads/(main|developer)'
,
regexpFilterText:
'$ref'
,
// 与webhook中配置的token参数值一致
token:
'18e75cb18358fdb6417f50973d8b9198'
)
}
stages
{
stage
(
'Fetch Code'
)
{
steps
{
updateGitlabCommitStatus
name:
"${CURRENT_JOB_NAME}-${Deploy}-${env.BRANCH_NAME}"
,
state:
'running'
script
{
if
(
params
.
Deploy
==
"Rollback"
&&
env
.
BRANCH_NAME
==
"main"
)
{
echo
"回滚到 $DeployVersion 版本"
sh
"git reset --hard $DeployVersion"
}
else
if
(
env
.
BRANCH_NAME
==
"main"
)
{
echo
"拉取 $DeployVersion 版本"
sh
"git checkout $DeployVersion"
}
else
{
echo
"拉取 最新 development 版本"
sh
"git checkout"
}
}
}
post
{
success
{
echo
"代码检出成功:)"
}
}
}
stage
(
'Build Image'
)
{
steps
{
// 只有发布的时候去打最新版的包,回滚不需要打包,那个版本的镜像已经有了
script
{
if
(
env
.
BRANCH_NAME
==
"main"
)
{
echo
"镜像构建..."
sh
"mv -f logtransfer-main.conf logtransfer.conf"
sh
"docker build --platform linux/amd64 -t docker.ijiwei.com/$APP_GROUP/$APP_NAME:$DeployVersion ."
echo
"正在上传Harbor..."
sh
"docker push docker.ijiwei.com/$APP_GROUP/$APP_NAME:$DeployVersion"
sh
"docker tag docker.ijiwei.com/$APP_GROUP/$APP_NAME:$DeployVersion docker.ijiwei.com/$APP_GROUP/$APP_NAME:latest"
sh
"docker push docker.ijiwei.com/$APP_GROUP/$APP_NAME:latest"
sh
"docker image rm docker.ijiwei.com/$APP_GROUP/$APP_NAME:$DeployVersion"
echo
"清除无用镜像..."
sh
"docker image prune -f"
}
else
{
echo
"镜像构建..."
sh
"mv -f logtransfer-dev.conf logtransfer.conf"
sh
"docker build --platform linux/amd64 -t docker.ijiwei.com/$APP_GROUP/$APP_NAME:dev ."
echo
"正在上传Harbor..."
sh
"docker push docker.ijiwei.com/$APP_GROUP/$APP_NAME:dev"
sh
"docker image rm docker.ijiwei.com/$APP_GROUP/$APP_NAME:dev"
echo
"清除无用镜像..."
sh
"docker image prune -f"
}
}
}
}
stage
(
'Deploy For Development'
)
{
when
{
branch
'developer'
}
steps
{
script
{
sshPublisher
(
failOnError:
true
,
publishers:
[
sshPublisherDesc
(
configName:
'dev_www'
,
transfers:
[
//注意路径!
sshTransfer
(
cleanRemote:
false
,
excludes:
''
,
execCommand:
"docker pull docker.ijiwei.com/${APP_GROUP}/${APP_NAME}:dev && docker tag docker.ijiwei.com/${APP_GROUP}/${APP_NAME}:dev ${APP_NAME}:dev && docker image rm docker.ijiwei.com/${APP_GROUP}/${APP_NAME}:dev && echo '运行镜像更新到 Development 版本'"
,
execTimeout:
120000
,
flatten:
false
,
makeEmptyDirs:
false
,
noDefaultExcludes:
false
,
patternSeparator:
'[, ]+'
,
remoteDirectory:
''
,
remoteDirectorySDF:
false
,
removePrefix:
''
,
sourceFiles:
''
),
sshTransfer
(
cleanRemote:
false
,
excludes:
''
,
execCommand:
"docker stop ${APP_NAME} && docker rm ${APP_NAME} && cd /home/www/web/${APP_NAME} && docker run --restart=always -d --name=${APP_NAME} --env-file=.env ${APP_NAME}:dev && docker image prune -f"
,
execTimeout:
120000
,
flatten:
false
,
makeEmptyDirs:
false
,
noDefaultExcludes:
false
,
patternSeparator:
'[, ]+'
,
remoteDirectory:
''
,
remoteDirectorySDF:
false
,
removePrefix:
''
,
sourceFiles:
''
)
],
usePromotionTimestamp:
false
,
useWorkspaceInPromotion:
false
,
verbose:
true
)
]
)
}
}
post
{
success
{
echo
"CCenter Dashboard 测试服务重启成功:)"
}
failure
{
echo
"CCenter Dashboard 测试服务重启失败:("
}
}
}
stage
(
'Deploy App'
)
{
when
{
branch
'master'
}
steps
{
updateGitlabCommitStatus
name:
"${CURRENT_JOB_NAME}-${Deploy}-${env.BRANCH_NAME}"
,
state:
'pending'
input
message:
"是否确认发布${DeployVersion}版本? (Click \"Proceed\" to continue)"
script
{
def
TargetVersion
=
"latest"
def
MethodType
=
"发布"
// 回滚的话取目标版本,否则事最新的
if
(
params
.
Deploy
==
"Rollback"
)
{
TargetVersion
=
DeployVersion
MethodType
=
"回滚"
}
sshPublisher
(
failOnError:
true
,
publishers:
[
sshPublisherDesc
(
configName:
'local_www'
,
transfers:
[
//注意路径!
sshTransfer
(
cleanRemote:
false
,
excludes:
''
,
execCommand:
"docker pull docker.ijiwei.com/${APP_GROUP}/${APP_NAME}:${TargetVersion} && docker tag docker.ijiwei.com/${APP_GROUP}/${APP_NAME}:${TargetVersion} ${APP_NAME}:latest && docker image rm docker.ijiwei.com/${APP_GROUP}/${APP_NAME}:${TargetVersion} && echo '运行镜像${MethodType}到 ${TargetVersion} 版本'"
,
execTimeout:
120000
,
flatten:
false
,
makeEmptyDirs:
false
,
noDefaultExcludes:
false
,
patternSeparator:
'[, ]+'
,
remoteDirectory:
''
,
remoteDirectorySDF:
false
,
removePrefix:
''
,
sourceFiles:
''
),
sshTransfer
(
cleanRemote:
false
,
excludes:
''
,
execCommand:
"docker stop ${APP_NAME} && docker rm ${APP_NAME} && cd /home/www/web/${APP_NAME} && docker run --restart=always -d --name=${APP_NAME} --env-file=.env ${APP_NAME}:latest && docker image prune -f"
,
execTimeout:
120000
,
flatten:
false
,
makeEmptyDirs:
false
,
noDefaultExcludes:
false
,
patternSeparator:
'[, ]+'
,
remoteDirectory:
''
,
remoteDirectorySDF:
false
,
removePrefix:
''
,
sourceFiles:
''
)
],
usePromotionTimestamp:
false
,
useWorkspaceInPromotion:
false
,
verbose:
true
)
]
)
}
}
post
{
success
{
echo
"CCenter Dashboard 正式环境服务重启成功:)"
}
failure
{
echo
"CCenter Dashboard 正式环境服务重启失败:("
}
}
}
}
post
{
success
{
updateGitlabCommitStatus
name:
"${CURRENT_JOB_NAME}-${Deploy}-${env.BRANCH_NAME}"
,
state:
'success'
}
failure
{
updateGitlabCommitStatus
name:
"${CURRENT_JOB_NAME}-${Deploy}-${env.BRANCH_NAME}"
,
state:
'failed'
}
unstable
{
updateGitlabCommitStatus
name:
"${CURRENT_JOB_NAME}-${Deploy}-${env.BRANCH_NAME}"
,
state:
'failed'
}
}
}
logtransfer-dev.conf
0 → 100644
View file @
470eedd7
# Kafka配置
[
kafka
]
address
=
http
://
120
.
25
.
235
.
220
:
9092
#Etcd配置
[
etcd
]
address
=
etcd0
:
23790
,
etcd1
:
23791
#Es配置
[
es
]
address
=
http
://
47
.
106
.
69
.
239
:
9320
bulk_size
=
2
\ No newline at end of file
logtransfer-main.conf
0 → 100644
View file @
470eedd7
# Kafka配置
[
kafka
]
address
=
http
://
120
.
25
.
235
.
220
:
9092
#Etcd配置
[
etcd
]
address
=
192
.
168
.
2
.
129
:
23790
,
192
.
168
.
2
.
129
:
23791
#Es配置
[
es
]
address
=
http
://
47
.
106
.
69
.
239
:
9320
bulk_size
=
2
\ No newline at end of file
source/topic.go
View file @
470eedd7
...
...
@@ -17,7 +17,11 @@ func generateTopic(config TopicConfig) *Topic {
// log.Println("get config", currentTopic.PipelineConfig)
for
_
,
v
:=
range
config
.
PipelineConfig
{
currentPlugin
:=
plugin
.
RegistedPlugins
[
v
.
Name
]
currentPlugin
,
ok
:=
plugin
.
RegistedPlugins
[
v
.
Name
]
if
!
ok
{
log
.
Printf
(
"get RegistedPlugins error:%s "
,
v
.
Name
)
continue
}
err
:=
currentPlugin
.
SetParams
(
v
.
Params
)
if
err
!=
nil
{
log
.
Panicln
(
"plugin encode params error:"
,
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment