Skip to content

Commit ded0341

Browse files
authored
Fix.jenkins2 (rancher#268)
Signed-off-by: Francisco <francisco.moral@suse.com>
1 parent a29866a commit ded0341

3 files changed

Lines changed: 43 additions & 29 deletions

File tree

pkg/testcase/support/ipv6only.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"sync"
99

1010
. "github.com/onsi/gomega"
11+
1112
"github.com/rancher/distros-test-framework/pkg/aws"
1213
"github.com/rancher/distros-test-framework/shared"
1314
)
@@ -196,9 +197,9 @@ func buildInstallCmd(cluster *shared.Cluster, nodeType, token, ip string) string
196197
product := cluster.Config.Product
197198
if nodeType == "master" && token == "" {
198199
cmdSlice = []string{
199-
os.Getenv("node_os"), cluster.FQDN, "", "", ip,
200-
os.Getenv("install_mode"), os.Getenv("install_version"), os.Getenv("install_channel"),
201-
os.Getenv("datastore_type"), os.Getenv("datastore_endpoint"), os.Getenv("server_flags"),
200+
cluster.NodeOS, cluster.FQDN, "", "", ip,
201+
cluster.Config.InstallMode, cluster.Config.Version, cluster.Config.Channel,
202+
cluster.Config.DataStore, cluster.Config.ExternalDbEndpoint, cluster.Config.ServerFlags,
202203
os.Getenv("username"), os.Getenv("password"), "both",
203204
}
204205
if product == "k3s" {
@@ -211,25 +212,25 @@ func buildInstallCmd(cluster *shared.Cluster, nodeType, token, ip string) string
211212

212213
if nodeType == "master" && token != "" {
213214
cmdSlice = []string{
214-
os.Getenv("node_os"), cluster.FQDN, cluster.ServerIPs[0], token, "", "", ip,
215-
os.Getenv("install_mode"), os.Getenv("install_version"), os.Getenv("install_channel"),
216-
os.Getenv("datastore_type"), os.Getenv("datastore_endpoint"), os.Getenv("server_flags"),
215+
cluster.NodeOS, cluster.FQDN, cluster.ServerIPs[0], token, "", "", ip,
216+
cluster.Config.InstallMode, cluster.Config.Version, cluster.Config.Channel,
217+
cluster.Config.DataStore, cluster.Config.ExternalDbEndpoint, cluster.Config.ServerFlags,
217218
os.Getenv("username"), os.Getenv("password"), "both",
218219
}
219220
if product == "rke2" {
220-
cmdSlice = slices.Insert(cmdSlice, 10, os.Getenv("install_method"))
221+
cmdSlice = slices.Insert(cmdSlice, 10, cluster.Config.InstallMethod)
221222
}
222223
script = "./join_" + product + "_" + nodeType + ".sh"
223224
}
224225

225226
if nodeType == "agent" {
226227
cmdSlice = []string{
227-
os.Getenv("node_os"), cluster.ServerIPs[0], token, "", "", ip,
228-
os.Getenv("install_mode"), os.Getenv("install_version"), os.Getenv("install_channel"),
229-
os.Getenv("worker_flags"), os.Getenv("username"), os.Getenv("password"), "both",
228+
cluster.NodeOS, cluster.ServerIPs[0], token, "", "", ip,
229+
cluster.Config.InstallMode, cluster.Config.Version, cluster.Config.Channel,
230+
cluster.Config.WorkerFlags, os.Getenv("username"), os.Getenv("password"), "both",
230231
}
231232
if product == "rke2" {
232-
cmdSlice = slices.Insert(cmdSlice, 9, os.Getenv("install_method"))
233+
cmdSlice = slices.Insert(cmdSlice, 9, cluster.Config.InstallMethod)
233234
}
234235
script = "./join_" + product + "_" + nodeType + ".sh"
235236
}

scripts/Jenkinsfile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ node {
2525
timeout = env.TIMEOUT
2626
}
2727

28+
def module = ""
29+
if (env.MODULE && env.MODULE != "null") {
30+
module = env.MODULE
31+
}
32+
2833
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm', 'defaultFg': 2, 'defaultBg': 1]) {
2934
withFolderProperties {
3035
def paramsMap = params.findAll { it.value?.trim() }.collectEntries { [(it.key): it.value] }
@@ -46,16 +51,16 @@ node {
4651
userRemoteConfigs: repo
4752
])
4853
}
49-
stage('Create QASE Environment Variables') {
50-
script {
51-
def qase = 'REPORT_TO_QASE=' + env.REPORT_TO_QASE + '\n' +
54+
stage('Create QASE Environment Variables') {
55+
script {
56+
def qase = 'REPORT_TO_QASE=' + env.REPORT_TO_QASE + '\n' +
5257
'QASE_PROJECT_ID=' + env.QASE_PROJECT_ID + '\n' +
5358
'QASE_RUN_ID=' + env.QASE_RUN_ID + '\n' +
5459
'QASE_TEST_CASE_ID=' + env.QASE_TEST_CASE_ID + '\n' +
5560
'QASE_AUTOMATION_TOKEN=' + env.QASE_AUTOMATION_TOKEN + '\n'
5661
writeFile file: qaseEnvFile, text: qase
57-
}
5862
}
63+
}
5964
dir('./') {
6065
try {
6166
stage('Configure and Build') {
@@ -68,12 +73,14 @@ node {
6873
dir('./config') {
6974
//update info in .env file
7075
def data = "ENV_PRODUCT=${env.PRODUCT_NAME}\nENV_TFVARS=${env.PRODUCT_NAME}.tfvars\n" +
71-
"KUBE_CONFIG=${env.KUBE_CONFIG}\nBASTION_IP=${env.BASTION_IP}\nLOG_LEVEL=${env.LOG_LEVEL}\nINSTALL_VERSION=${env.INSTALL_VERSION}\n"
72-
def version_param_name = "${env.PRODUCT_NAME}_version"
73-
def channel_param_name = "${env.PRODUCT_NAME}_channel"
76+
"KUBE_CONFIG=${env.KUBE_CONFIG}\nBASTION_IP=${env.BASTION_IP}\nLOG_LEVEL=${env.LOG_LEVEL}\nINSTALL_VERSION=${env.INSTALL_VERSION}\n" +
77+
"ENV_MODULE=${module}\nINSTALL_CHANNEL=${env.INSTALL_CHANNEL}\n"
7478
//adding data to .env file
7579
writeFile(file: '.env', text: data)
80+
7681
//update tfvars file
82+
def version_param_name = "${env.PRODUCT_NAME}_version"
83+
def channel_param_name = "${env.PRODUCT_NAME}_channel"
7784
def filename = "${env.PRODUCT_NAME}.tfvars"
7885
def configContents = env.TFVARS
7986
writeFile file: filename, text: configContents +
@@ -90,8 +97,8 @@ node {
9097
println(testdata)
9198
}
9299
stage('Docker Build') {
93-
sh './scripts/configure.sh'
94-
sh './scripts/build.sh'
100+
sh './scripts/configure.sh'
101+
sh './scripts/build.sh'
95102
}
96103
}
97104
stage('Run TestCombination') {
@@ -104,7 +111,7 @@ node {
104111
${imageName} sh -c "env && chmod 400 /go/src/github.com/rancher/distros-test-framework/config/.ssh/aws_key.pem && \
105112
cd ./entrypoint && go test -timeout=${timeout} -v ./${env.TEST_DIRECTORY}/... ${env.TEST_ARGS.replace('\"', '\\\"')}"
106113
"""
107-
}
114+
}
108115
} finally {
109116
stage('Cleanup') {
110117
sh "docker stop ${testContainer} || true"

shared/terraform.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func loadTFconfig(
8989

9090
LogLevel("info", "Loading Version and Channel...")
9191
loadVersion(t, c, varDir)
92-
loadChannel(t, c, module, varDir)
92+
loadChannel(t, c, varDir)
9393

9494
if c.Config.Product == "rke2" {
9595
c.Config.InstallMethod = terraform.GetVariableAsStringFromVarFile(t, varDir, "install_method")
@@ -103,6 +103,7 @@ func loadTFconfig(
103103
//
104104
// this is being really messy and painful. remove after.
105105
func loadVersion(t *testing.T, c *Cluster, varDir string) {
106+
// defaults first always to get from env, because both local and jenkins we update this file
106107
if install := os.Getenv("INSTALL_VERSION"); install != "" {
107108
c.Config.Version = install
108109
LogLevel("info", "Using install version from env: %s", install)
@@ -117,15 +118,20 @@ func loadVersion(t *testing.T, c *Cluster, varDir string) {
117118
}
118119
}
119120

120-
func loadChannel(t *testing.T, c *Cluster, module, varDir string) {
121+
func loadChannel(t *testing.T, c *Cluster, varDir string) {
122+
// defaults first always to get from env, because both local and jenkins we update this file
123+
if envInstallChannel := os.Getenv("INSTALL_CHANNEL"); envInstallChannel != "" {
124+
c.Config.Channel = envInstallChannel
125+
LogLevel("info", "Using install channel from env INSTALL_CHANNEL: %s", envInstallChannel)
126+
return
127+
}
128+
121129
tfChannel := c.Config.Product + "_channel"
122130

123-
if module != "airgap" && module != "ipv6only" {
124-
if tf := terraform.GetVariableAsStringFromVarFile(t, varDir, tfChannel); tf != "" {
125-
c.Config.Channel = tf
126-
LogLevel("info", "Using install channel from tfvars: %s", tf)
127-
return
128-
}
131+
if tf := terraform.GetVariableAsStringFromVarFile(t, varDir, tfChannel); tf != "" {
132+
c.Config.Channel = tf
133+
LogLevel("info", "Using install channel from tfvars: %s", tf)
134+
return
129135
}
130136

131137
if install := os.Getenv("install_channel"); install != "" {

0 commit comments

Comments
 (0)