Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
devops-dev
Project
Project
Details
Activity
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
demo
devops-dev
Commits
d7bc3128
Commit
d7bc3128
authored
Sep 27, 2019
by
梦良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交
parent
e72c8a67
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
139 deletions
+99
-139
job.go
controllers/job.go
+99
-27
Jenkinsfile
jenkins/Jenkinsfile
+0
-112
No files found.
controllers/job.go
View file @
d7bc3128
...
@@ -188,6 +188,7 @@ func (c *JobController) GetJobList() {
...
@@ -188,6 +188,7 @@ func (c *JobController) GetJobList() {
result
=
append
(
result
,
o
)
result
=
append
(
result
,
o
)
}
}
successResponseDto
.
Status
=
200
successResponseDto
.
Result
=
result
successResponseDto
.
Result
=
result
successResponseDto
.
PageInfo
=
dto
.
PageInfoBaseResponseDto
{
successResponseDto
.
PageInfo
=
dto
.
PageInfoBaseResponseDto
{
TotalRecords
:
totalRecords
,
TotalRecords
:
totalRecords
,
...
@@ -640,7 +641,7 @@ func (c *JobController) CreatePipelineJob() {
...
@@ -640,7 +641,7 @@ func (c *JobController) CreatePipelineJob() {
gitBaseUrl
:=
requestDto
.
GitBaseUrl
gitBaseUrl
:=
requestDto
.
GitBaseUrl
branch
:=
requestDto
.
Branch
branch
:=
requestDto
.
Branch
buildScriptPath
:=
requestDto
.
BuildScriptPath
buildScriptPath
:=
requestDto
.
BuildScriptPath
credentialId
:=
requestDto
.
CredentialId
//
credentialId := requestDto.CredentialId
listeningEvents
:=
requestDto
.
ListeningEvents
listeningEvents
:=
requestDto
.
ListeningEvents
//执行创建job
//执行创建job
...
@@ -655,21 +656,14 @@ func (c *JobController) CreatePipelineJob() {
...
@@ -655,21 +656,14 @@ func (c *JobController) CreatePipelineJob() {
infoLogger
.
Printf
(
"执行配置job:%s"
,
jobName
)
infoLogger
.
Printf
(
"执行配置job:%s"
,
jobName
)
//执行配置job
params
:=
"description="
+
url
.
QueryEscape
(
description
)
+
params
:=
"description="
+
url
.
QueryEscape
(
description
)
+
"&stapler-class-bag=true&_.daysToKeepStr=&_.numToKeepStr=&_.artifactDaysToKeepStr="
+
"&stapler-class-bag=true&_.daysToKeepStr=&_.numToKeepStr=&_.artifactDaysToKeepStr="
+
"&_.artifactNumToKeepStr=&stapler-class=hudson.tasks.LogRotator&%24class="
+
"&_.artifactNumToKeepStr=&stapler-class=hudson.tasks.LogRotator&%24class="
+
"hudson.tasks.LogRotator&_.projectUrlStr=&_.displayName=&_.gitLabConnection=&hint="
+
"hudson.tasks.LogRotator&_.projectUrlStr=&_.displayName=&_.gitLabConnection=&hint="
+
"MAX_SURVIVABILITY&_.buildCount=1&_.count=1&_.durationName=second&stapler-class-bag="
+
"MAX_SURVIVABILITY&_.buildCount=1&_.count=1&_.durationName=second&stapler-class-bag="
+
"true&_.upstreamProjects=&ReverseBuildTrigger.threshold=SUCCESS&_.spec="
"true&_.upstreamProjects=&ReverseBuildTrigger.threshold=SUCCESS&_.spec="
+
"&com-dabsquared-gitlabjenkins-GitLabPushTrigger=on&_.triggerOnPush=on"
+
if
listeningEvents
.
Push
{
"&_.triggerOpenMergeRequestOnPush=never&_.noteRegex=Jenkins+please+retry+a+build&_.ciSkip="
+
params
+=
"&com-dabsquared-gitlabjenkins-GitLabPushTrigger=on"
+
"&_.triggerOnPush=on"
}
params
+=
"&_.triggerOpenMergeRequestOnPush=never&_.noteRegex=Jenkins+please+retry+a+build&_.ciSkip="
+
"on&_.skipWorkInProgressMergeRequest=on&_.setBuildDescription=on&_.pendingBuildName="
+
"on&_.skipWorkInProgressMergeRequest=on&_.setBuildDescription=on&_.pendingBuildName="
+
"&branchFilterType=All&includeBranchesSpec=&excludeBranchesSpec=&sourceBranchRegex="
+
"&branchFilterType=All&includeBranchesSpec=&excludeBranchesSpec=&sourceBranchRegex="
+
"&targetBranchRegex=&include=&exclude=&_.secretToken=&_.scmpoll_spec=&quiet_period=5"
+
"&targetBranchRegex=&include=&exclude=&_.secretToken=&_.scmpoll_spec=&quiet_period=5"
+
...
@@ -677,9 +671,11 @@ func (c *JobController) CreatePipelineJob() {
...
@@ -677,9 +671,11 @@ func (c *JobController) CreatePipelineJob() {
"org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition&%24class="
+
"org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition&%24class="
+
"org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition&stapler-class=hudson.scm.NullSCM&%24class=hudson.scm.NullSCM"
+
"org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition&stapler-class=hudson.scm.NullSCM&%24class=hudson.scm.NullSCM"
+
"&_.url="
+
url
.
QueryEscape
(
gitBaseUrl
)
+
"&_.url="
+
url
.
QueryEscape
(
gitBaseUrl
)
+
"&_.credentialsId="
+
url
.
QueryEscape
(
credentialId
)
+
"&_.name=&_.refspec="
+
"&_.credentialsId="
+
"&_.name=*%2F"
+
url
.
QueryEscape
(
branch
)
+
"&stapler-class="
+
"&_.name=&_.refspec="
+
"hudson.plugins.git.browser.AssemblaWeb&%24class=hudson.plugins.git.browser.AssemblaWeb&stapler-class="
+
"&_.name=*%2F"
+
url
.
QueryEscape
(
branch
)
+
"&stapler-class=hudson.plugins.git.browser.AssemblaWeb&%24class="
+
"hudson.plugins.git.browser.AssemblaWeb&stapler-class="
+
"hudson.plugins.git.browser.FisheyeGitRepositoryBrowser&%24class="
+
"hudson.plugins.git.browser.FisheyeGitRepositoryBrowser&%24class="
+
"hudson.plugins.git.browser.FisheyeGitRepositoryBrowser&stapler-class="
+
"hudson.plugins.git.browser.FisheyeGitRepositoryBrowser&stapler-class="
+
"hudson.plugins.git.browser.KilnGit&%24class=hudson.plugins.git.browser.KilnGit&stapler-class="
+
"hudson.plugins.git.browser.KilnGit&%24class=hudson.plugins.git.browser.KilnGit&stapler-class="
+
...
@@ -723,13 +719,10 @@ func (c *JobController) CreatePipelineJob() {
...
@@ -723,13 +719,10 @@ func (c *JobController) CreatePipelineJob() {
"%22%3A+%7B%22specified%22%3A+false%2C+%22buildCount%22%3A+%221%22%7D%2C+%22"
+
"%22%3A+%7B%22specified%22%3A+false%2C+%22buildCount%22%3A+%221%22%7D%2C+%22"
+
"hudson-model-ParametersDefinitionProperty%22%3A+%7B%22specified%22%3A+false%7D%2C+%22"
+
"hudson-model-ParametersDefinitionProperty%22%3A+%7B%22specified%22%3A+false%7D%2C+%22"
+
"jenkins-branch-RateLimitBranchProperty%24JobPropertyImpl%22%3A+%7B%7D%2C+%22"
+
"jenkins-branch-RateLimitBranchProperty%24JobPropertyImpl%22%3A+%7B%7D%2C+%22"
+
"org-jenkinsci-plugins-workflow-job-properties-PipelineTriggersJobProperty%22%3A+%7B%22"
"org-jenkinsci-plugins-workflow-job-properties-PipelineTriggersJobProperty%22%3A+%7B%22"
+
"triggers%22%3A+%7B%22stapler-class-bag%22%3A+%22true%22%2C+%22"
+
if
listeningEvents
.
Push
{
"com-dabsquared-gitlabjenkins-GitLabPushTrigger%22%3A+%7B%22triggerOnPush%22%3A+true%2C+%22"
+
params
+=
"triggers%22%3A+%7B%22stapler-class-bag%22%3A+%22true%22%2C+%22"
+
"triggerOnMergeRequest%22%3A+false%2C+%22triggerOnAcceptedMergeRequest%22%3A+false%2C+%22"
+
"com-dabsquared-gitlabjenkins-GitLabPushTrigger%22%3A+%7B%22triggerOnPush%22%3A+true%2C+%22"
}
params
+=
"triggerOnMergeRequest%22%3A+false%2C+%22triggerOnAcceptedMergeRequest%22%3A+false%2C+%22"
+
"triggerOnClosedMergeRequest%22%3A+false%2C+%22triggerOpenMergeRequestOnPush%22%3A+%22"
+
"triggerOnClosedMergeRequest%22%3A+false%2C+%22triggerOpenMergeRequestOnPush%22%3A+%22"
+
"never%22%2C+%22triggerOnApprovedMergeRequest%22%3A+false%2C+%22triggerOnNoteRequest"
+
"never%22%2C+%22triggerOnApprovedMergeRequest%22%3A+false%2C+%22triggerOnNoteRequest"
+
"%22%3A+false%2C+%22noteRegex%22%3A+%22Jenkins+please+retry+a+build%22%2C+%22ciSkip"
+
"%22%3A+false%2C+%22noteRegex%22%3A+%22Jenkins+please+retry+a+build%22%2C+%22ciSkip"
+
...
@@ -742,20 +735,99 @@ func (c *JobController) CreatePipelineJob() {
...
@@ -742,20 +735,99 @@ func (c *JobController) CreatePipelineJob() {
"quiet_period%22%3A+%225%22%2C+%22displayNameOrNull%22%3A+%22%22%2C+%22%22%3A+%221%22%2C+%22definition"
+
"quiet_period%22%3A+%225%22%2C+%22displayNameOrNull%22%3A+%22%22%2C+%22%22%3A+%221%22%2C+%22definition"
+
"%22%3A+%7B%22%22%3A+%221%22%2C+%22scm%22%3A+%7B%22userRemoteConfigs%22%3A+%7B%22"
+
"%22%3A+%7B%22%22%3A+%221%22%2C+%22scm%22%3A+%7B%22userRemoteConfigs%22%3A+%7B%22"
+
"url%22%3A+%22"
+
url
.
QueryEscape
(
gitBaseUrl
)
+
"%22%2C+%22"
+
"url%22%3A+%22"
+
url
.
QueryEscape
(
gitBaseUrl
)
+
"%22%2C+%22"
+
//"https%3A%2F%2Fgit.k2software.com.cn%2FPaaS%2Fgolang-jenkins.git%22%2C+%22" +
"credentialsId%22%3A+%22%22%2C+%22"
+
"credentialsId%22%3A+%22"
+
url
.
QueryEscape
(
credentialId
)
+
"name%22%3A+%22%22%2C+%22refspec%22%3A+%22%22%7D%2C+%22branches%22%3A+%7B%22"
+
//"%22%3A+%226153b449-f61f-4af7-b0d8-cd897a50fc60%22" +
"%22%2C+%22name%22%3A+%22%22%2C+%22refspec%22%3A+%22%22%7D%2C+%22branches%22%3A+%7B%22"
+
"name%22%3A+%22*%2F"
+
url
.
QueryEscape
(
branch
)
+
"%22%7D%2C+%22%22%3A+%22auto"
+
"name%22%3A+%22*%2F"
+
url
.
QueryEscape
(
branch
)
+
"%22%7D%2C+%22%22%3A+%22auto"
+
//"name%22%3A+%22*%2Fmaster%22%7D%2C+%22%22%3A+%22auto" +
"%22%2C+%22stapler-class%22%3A+%22hudson.plugins.git.GitSCM%22%2C+%22%24class%22%3A+%22"
+
"%22%2C+%22stapler-class%22%3A+%22hudson.plugins.git.GitSCM%22%2C+%22%24class%22%3A+%22"
+
"hudson.plugins.git.GitSCM%22%7D%2C+%22"
+
"hudson.plugins.git.GitSCM%22%7D%2C+%22"
+
"scriptPath%22%3A+%22"
+
url
.
QueryEscape
(
buildScriptPath
)
+
"scriptPath%22%3A+%22"
+
url
.
QueryEscape
(
buildScriptPath
)
+
//"scriptPath%22%3A+%22Jenkinsfile%22" +
"%22%2C+%22lightweight%22%3A+true%2C+%22stapler-class%22%3A+%22org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition"
+
"%22%2C+%22lightweight%22%3A+true%2C+%22stapler-class%22%3A+%22org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition"
+
"%22%2C+%22%24class%22%3A+%22org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition"
+
"%22%2C+%22%24class%22%3A+%22org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition"
+
"%22%7D%2C+%22core%3Aapply%22%3A+%22%22%7D&Submit=%E4%BF%9D%E5%AD%98"
"%22%7D%2C+%22core%3Aapply%22%3A+%22%22%7D&Submit=%E4%BF%9D%E5%AD%98"
// 没有选择监听push事件
if
!
listeningEvents
.
Push
{
params
=
"description="
+
url
.
QueryEscape
(
description
)
+
"&stapler-class-bag=true&_.daysToKeepStr="
+
"&_.numToKeepStr=&_.artifactDaysToKeepStr=&_.artifactNumToKeepStr="
+
"&stapler-class=hudson.tasks.LogRotator&%24class=hudson.tasks.LogRotator&_.projectUrlStr="
+
"&_.displayName=&_.gitLabConnection=&hint=MAX_SURVIVABILITY&_.buildCount=1&_.count=1"
+
"&_.durationName=second&stapler-class-bag=true&_.upstreamProjects="
+
"&ReverseBuildTrigger.threshold=SUCCESS&_.spec=&_.triggerOpenMergeRequestOnPush=never&_.noteRegex="
+
"Jenkins+please+retry+a+build&_.ciSkip=on&_.skipWorkInProgressMergeRequest=on&_.setBuildDescription=on"
+
"&_.pendingBuildName=&branchFilterType=All&includeBranchesSpec=&excludeBranchesSpec="
+
"&sourceBranchRegex=&targetBranchRegex=&include=&exclude=&_.secretToken=&_.scmpoll_spec="
+
"&quiet_period=5&_.displayNameOrNull=&stapler-class="
+
"org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition&%24class="
+
"org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition"
+
"&_.url="
+
url
.
QueryEscape
(
gitBaseUrl
)
+
"&_.credentialsId="
+
"&_.name=&_.refspec="
+
"&_.name=*%2F"
+
url
.
QueryEscape
(
branch
)
+
"&stapler-class=hudson.plugins.git.browser.AssemblaWeb&%24class="
+
"hudson.plugins.git.browser.AssemblaWeb&stapler-class="
+
"hudson.plugins.git.browser.FisheyeGitRepositoryBrowser&%24class="
+
"hudson.plugins.git.browser.FisheyeGitRepositoryBrowser&stapler-class="
+
"hudson.plugins.git.browser.KilnGit&%24class=hudson.plugins.git.browser.KilnGit&stapler-class="
+
"hudson.plugins.git.browser.TFS2013GitRepositoryBrowser&%24class="
+
"hudson.plugins.git.browser.TFS2013GitRepositoryBrowser&stapler-class="
+
"hudson.plugins.git.browser.BitbucketWeb&%24class=hudson.plugins.git.browser.BitbucketWeb&stapler-class="
+
"hudson.plugins.git.browser.CGit&%24class=hudson.plugins.git.browser.CGit&stapler-class="
+
"hudson.plugins.git.browser.GitBlitRepositoryBrowser&%24class="
+
"hudson.plugins.git.browser.GitBlitRepositoryBrowser&stapler-class="
+
"hudson.plugins.git.browser.GithubWeb&%24class=hudson.plugins.git.browser.GithubWeb&stapler-class="
+
"hudson.plugins.git.browser.Gitiles&%24class=hudson.plugins.git.browser.Gitiles&stapler-class="
+
"hudson.plugins.git.browser.GitLab&%24class=hudson.plugins.git.browser.GitLab&stapler-class="
+
"hudson.plugins.git.browser.GitList&%24class=hudson.plugins.git.browser.GitList&stapler-class="
+
"hudson.plugins.git.browser.GitoriousWeb&%24class=hudson.plugins.git.browser.GitoriousWeb&stapler-class="
+
"hudson.plugins.git.browser.GitWeb&%24class=hudson.plugins.git.browser.GitWeb&stapler-class="
+
"hudson.plugins.git.browser.GogsGit&%24class=hudson.plugins.git.browser.GogsGit&stapler-class="
+
"hudson.plugins.git.browser.Phabricator&%24class=hudson.plugins.git.browser.Phabricator&stapler-class="
+
"hudson.plugins.git.browser.RedmineWeb&%24class=hudson.plugins.git.browser.RedmineWeb&stapler-class="
+
"hudson.plugins.git.browser.RhodeCode&%24class=hudson.plugins.git.browser.RhodeCode&stapler-class="
+
"hudson.plugins.git.browser.Stash&%24class=hudson.plugins.git.browser.Stash&stapler-class="
+
"hudson.plugins.git.browser.ViewGitWeb&%24class=hudson.plugins.git.browser.ViewGitWeb&stapler-class="
+
"hudson.plugins.git.GitSCM&%24class=hudson.plugins.git.GitSCM&stapler-class="
+
"hudson.plugins.mercurial.MercurialSCM&%24class=hudson.plugins.mercurial.MercurialSCM"
+
"&_.scriptPath="
+
url
.
QueryEscape
(
buildScriptPath
)
+
"&_.lightweight=on&stapler-class=org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition&%24class="
+
"org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition&core%3Aapply="
+
"&json=%7B%22description%22%3A+%22"
+
url
.
QueryEscape
(
description
)
+
"%22%2C+%22properties%22%3A+%7B%22stapler-class-bag%22%3A+%22true%22%2C+%22"
+
"hudson-plugins-jira-JiraProjectProperty%22%3A+%7B%22siteName%22%3A+%22%22%7D%2C+%22"
+
"jenkins-model-BuildDiscarderProperty%22%3A+%7B%22specified%22%3A+false%2C+%22%22%3A+%220%22%2C+%22"
+
"strategy%22%3A+%7B%22daysToKeepStr%22%3A+%22%22%2C+%22numToKeepStr%22%3A+%22%22%2C+%22"
+
"artifactDaysToKeepStr%22%3A+%22%22%2C+%22artifactNumToKeepStr%22%3A+%22%22%2C+%22stapler-class"
+
"%22%3A+%22hudson.tasks.LogRotator%22%2C+%22%24class%22%3A+%22"
+
"hudson.tasks.LogRotator%22%7D%7D%2C+%22"
+
"org-jenkinsci-plugins-workflow-job-properties-DisableConcurrentBuildsJobProperty%22%3A+%7B%22"
+
"specified%22%3A+false%7D%2C+%22org-jenkinsci-plugins-workflow-job-properties-DisableResumeJobProperty"
+
"%22%3A+%7B%22specified%22%3A+false%7D%2C+%22com-coravy-hudson-plugins-github-GithubProjectProperty"
+
"%22%3A+%7B%7D%2C+%22com-dabsquared-gitlabjenkins-connection-GitLabConnectionProperty%22%3A+%7B%22"
+
"gitLabConnection%22%3A+%22%22%7D%2C+%22org-jenkinsci-plugins-workflow-job-properties-DurabilityHintJobProperty"
+
"%22%3A+%7B%22specified%22%3A+false%2C+%22hint%22%3A+%22MAX_SURVIVABILITY%22%7D%2C+%22"
+
"org-jenkinsci-plugins-pipeline-modeldefinition-properties-PreserveStashesJobProperty"
+
"%22%3A+%7B%22specified%22%3A+false%2C+%22buildCount%22%3A+%221%22%7D%2C+%22"
+
"hudson-model-ParametersDefinitionProperty%22%3A+%7B%22specified%22%3A+false%7D%2C+%22"
+
"jenkins-branch-RateLimitBranchProperty%24JobPropertyImpl%22%3A+%7B%7D%2C+%22"
+
"org-jenkinsci-plugins-workflow-job-properties-PipelineTriggersJobProperty%22%3A+%7B%22"
+
"triggers%22%3A+%7B%22stapler-class-bag%22%3A+%22true%22%7D%7D%7D%2C+%22disable"
+
"%22%3A+false%2C+%22hasCustomQuietPeriod%22%3A+false%2C+%22quiet_period%22%3A+%225%22%2C+%22"
+
"displayNameOrNull%22%3A+%22%22%2C+%22%22%3A+%221%22%2C+%22definition%22%3A+%7B%22%22%3A+%220%22%2C+%22"
+
"scm%22%3A+%7B%22userRemoteConfigs%22%3A+%7B%22"
+
"url%22%3A+%22"
+
url
.
QueryEscape
(
gitBaseUrl
)
+
"%22%2C+%22"
+
"credentialsId%22%3A+%22%22%2C+%22"
+
"name%22%3A+%22%22%2C+%22refspec%22%3A+%22%22%7D%2C+%22branches%22%3A+%7B%22"
+
"name%22%3A+%22*%2F"
+
url
.
QueryEscape
(
branch
)
+
"%22%7D%2C+%22%22%3A+%22"
+
"auto%22%2C+%22stapler-class%22%3A+%22hudson.plugins.git.GitSCM%22%2C+%22%24class%22%3A+%22"
+
"hudson.plugins.git.GitSCM%22%7D%2C+%22"
+
"scriptPath%22%3A+%22"
+
url
.
QueryEscape
(
buildScriptPath
)
+
"%22%2C+%22lightweight%22%3A+true%2C+%22stapler-class"
+
"%22%3A+%22org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition%22%2C+%22%24class%22%3A+%22"
+
"org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition%22%7D%2C+%22core%3Aapply%22%3A+%22%22%7D"
+
"&Submit=%E4%BF%9D%E5%AD%98"
}
const
BaseUrl
=
"http://jenkins.poc.paas.com"
const
BaseUrl
=
"http://jenkins.poc.paas.com"
configSubmitUrl
:=
BaseUrl
+
"/job/"
+
jobName
+
"/configSubmit"
configSubmitUrl
:=
BaseUrl
+
"/job/"
+
jobName
+
"/configSubmit"
...
...
jenkins/Jenkinsfile
deleted
100644 → 0
View file @
e72c8a67
#
!
/usr/
bin
/
env
groovy
def
projectProperties
=
[
[
$class
:
'BuildDiscarderProperty'
,
strategy:
[
$class
:
'LogRotator'
,
numToKeepStr:
'5'
]],
parameters
([
string
(
name:
'DOCKER_USER'
,
defaultValue:
'admin'
,
description:
'docker用户名'
),
string
(
name:
'DOCKER_PASSWORD'
,
defaultValue:
'K2pass!!'
,
description:
'docker用户密码'
),
string
(
name:
'REGISTRY_URL'
,
defaultValue:
'harbor.dev.k2paas.com'
,
description:
'docker仓库地址'
)
]),
pipelineTriggers
([
[
$class
:
'GitLabPushTrigger'
,
branchFilterType:
'All'
,
triggerOnPush:
false
,
triggerOnMergeRequest:
false
,
triggerOpenMergeRequestOnPush:
"never"
,
triggerOnNoteRequest:
false
,
triggerOnAcceptedMergeRequest:
true
,
noteRegex:
"Jenkins please retry a build"
,
skipWorkInProgressMergeRequest:
true
,
ciSkip:
true
,
setBuildDescription:
true
,
addNoteOnMergeRequest:
true
,
addCiMessage:
true
,
addVoteOnMergeRequest:
true
,
acceptMergeRequestOnSuccess:
true
,
]
])
]
properties
(
projectProperties
)
def
label
=
"mypod-${UUID.randomUUID().toString()}"
podTemplate
(
label:
label
,
cloud:
'kubernetes'
,
containers:
[
containerTemplate
(
name:
'golang'
,
image:
'harbor.k2software.com.cn/library/golang:1.12-alpine'
,
command:
'cat'
,
ttyEnabled:
true
),
containerTemplate
(
name:
'docker'
,
image:
'harbor.k2software.com.cn/build/docker:latest'
,
command:
'cat'
,
ttyEnabled:
true
),
containerTemplate
(
name:
'helm'
,
image:
'harbor.k2software.com.cn/build/helm:v2.11.0'
,
command:
'cat'
,
ttyEnabled:
true
,
envVars:
[
envVar
(
key:
'KUBECONFIG'
,
value:
'/root/.kube/config'
)])
],
volumes:
[
hostPathVolume
(
hostPath:
'/var/run/docker.sock'
,
mountPath:
'/var/run/docker.sock'
),
hostPathVolume
(
hostPath:
'/root/.kube'
,
mountPath:
'/root/.kube'
),
hostPathVolume
(
hostPath:
'/root/.m2'
,
mountPath:
'/root/.m2'
),
hostPathVolume
(
hostPath:
'/root/.helm'
,
mountPath:
'/home/jenkins/.helm'
)
])
{
node
(
label
)
{
def
version
=
"v6.0"
stage
(
'checkout'
)
{
checkout
scm
sh
'printenv'
}
container
(
'golang'
)
{
stage
(
'build'
)
{
sh
'ls -al'
// 生成静态链接所有的库
sh
'CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -v -mod vendor -o k8s-console'
}
//stage('copy-front') {
// def dist_dir = "/mnt/k8s/online/${version}/front/k8s_console_front/dist"
// sh "cp -r $dist_dir frontend/"
//}
}
container
(
'docker'
)
{
//def tarName = "/mnt/k8s/online/${version}/images/paas-k8s-console_dev-${env.BUILD_ID}.tar"
stage
(
'docker-login'
)
{
//REGISTRY_URL私有仓库地址,也可使用官方地址:docker.io
sh
"docker login -u ${params.DOCKER_USER} -p ${params.DOCKER_PASSWORD} ${params.REGISTRY_URL}"
}
stage
(
'docker-build'
)
{
sh
"docker build . -t ${params.REGISTRY_URL}/paas-dev/paas-k8s-console:dev-${env.BUILD_ID}"
}
stage
(
'docker-push'
)
{
sh
"docker push ${params.REGISTRY_URL}/paas-dev/paas-k8s-console:dev-${env.BUILD_ID}"
}
// stage('docker-save') {
// sh "rm -rf /mnt/k8s/online/${version}/images/paas-k8s-console_*.tar"
// sh "docker save ${params.REGISTRY_URL}/paas-dev/paas-k8s-console:dev-${env.BUILD_ID} > $tarName"
// }
stage
(
'docker-rmi'
)
{
sh
"docker rmi ${params.REGISTRY_URL}/paas-dev/paas-k8s-console:dev-${env.BUILD_ID}"
}
}
//container('helm') {
// stage('helm deploy') {
// sh "sed -i \"s/tag: dev/tag: dev-${env.BUILD_ID}/g\" k8s-console-chart/values-dev.yaml"
// sh "helm upgrade --install k8s-console --namespace paas k8s-console-chart/ -f k8s-console-chart/values-dev.yaml"
//
// def previewTarget = "/mnt/k8s/online/${version}/charts"
// if(!fileExists("${previewTarget}")) {
// sh "mkdir -p ${previewTarget}"
// }
// sh "cp -r k8s-console-chart ${previewTarget}/"
// }
//}
}
}
// vim: ft=groovy
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