From 208f180b47abb3c13ba1a7374c7bef1d3873bd57 Mon Sep 17 00:00:00 2001 From: colynn Date: Fri, 26 Nov 2021 17:08:42 +0800 Subject: [PATCH] upgrade* jenkins runtime vars use envVars uniformly --- jenkins/config.go | 8 +------- jenkins/jenkins_test.go | 1 - jenkins/templates/cipipeline.go | 2 +- jenkins/templates/deploy.go | 2 +- sample/sample.go | 5 +---- 5 files changed, 4 insertions(+), 14 deletions(-) diff --git a/jenkins/config.go b/jenkins/config.go index 793d71c..14b3613 100644 --- a/jenkins/config.go +++ b/jenkins/config.go @@ -20,10 +20,7 @@ import "github.com/go-atomci/workflow" // CommonContext .. type CommonContext struct { - JenkinsSlaveWorkspace string - AccessToken string - RepoCnf string - AtomCIServer string + Namespace string } // CallbackRequest .. @@ -58,9 +55,6 @@ type ContainerEnv struct { // CIContext .. type CIContext struct { CommonContext - RegistryAddr string - DockerConfig string - DockerAuth string Stages string EnvVars []EnvItem ContainerTemplates []ContainerEnv diff --git a/jenkins/jenkins_test.go b/jenkins/jenkins_test.go index a01eff8..c99961d 100644 --- a/jenkins/jenkins_test.go +++ b/jenkins/jenkins_test.go @@ -47,7 +47,6 @@ func TestGetStatus(t *testing.T) { pipelineStagesStr := strings.Join(taskPipelineXMLStrArr, " ") CIContext := CIContext{ - RegistryAddr: "", EnvVars: []EnvItem{ {Key: "JENKINS_SLAVE_WORKSPACE", Value: "/tmp"}, {Key: "ACCESS_TOKEN", Value: "dddxxx"}, diff --git a/jenkins/templates/cipipeline.go b/jenkins/templates/cipipeline.go index f7dd5e6..94df058 100644 --- a/jenkins/templates/cipipeline.go +++ b/jenkins/templates/cipipeline.go @@ -26,7 +26,7 @@ pipeline { apiVersion: v1 kind: Pod metadata: - namespace: devops + namespace: {{ .Namespace }} spec: containers: {{- range $i, $item := .ContainerTemplates }} diff --git a/jenkins/templates/deploy.go b/jenkins/templates/deploy.go index b7249cb..f652c71 100644 --- a/jenkins/templates/deploy.go +++ b/jenkins/templates/deploy.go @@ -26,7 +26,7 @@ pipeline { apiVersion: v1 kind: Pod metadata: - namespace: devops + namespace: {{ .Namespace }} spec: containers: {{- range $i, $item := .ContainerTemplates }} diff --git a/sample/sample.go b/sample/sample.go index 4024fa0..93f7adc 100644 --- a/sample/sample.go +++ b/sample/sample.go @@ -98,14 +98,11 @@ func SamplePipeline(addr, user, token string) error { // Notes // pipelineStageStr: you can use `jenkins.GeneratePipelineXMLStr()` get the defined of pipelineXmlStr. flowProcessor := &jenkins.CIContext{ - RegistryAddr: "192.168.2.10:5000", EnvVars: envVars, ContainerTemplates: containerTemplates, Stages: GetPipelineXMLStr(), CommonContext: jenkins.CommonContext{ - JenkinsSlaveWorkspace: "CIInfo[3]", - AccessToken: "adminToken", - AtomCIServer: "atomciServer", + Namespace: "devops", }, CallBack: jenkins.CallbackRequest{ Token: token,