func jenkinsJobBytes(filename, namespace string) []byte { pre := exutil.FixturePath("fixtures", filename) post := exutil.ArtifactPath(filename) err := exutil.VarSubOnFile(pre, post, "PROJECT_NAME", namespace) o.Expect(err).NotTo(o.HaveOccurred()) data, err := ioutil.ReadFile(post) o.Expect(err).NotTo(o.HaveOccurred()) return data }
// Returns the content of a Jenkins job XML file. Instances of the // string "PROJECT_NAME" are replaced with the specified namespace. func (j *JenkinsRef) readJenkinsJob(filename, namespace string) string { pre := exutil.FixturePath("testdata", "jenkins-plugin", filename) post := exutil.ArtifactPath(filename) err := exutil.VarSubOnFile(pre, post, "PROJECT_NAME", namespace) o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred()) data, err := ioutil.ReadFile(post) o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred()) return string(data) }
// ReadJenkinsJobUsingVars returns the content of a Jenkins job XML file. Instances of the // string "PROJECT_NAME" are replaced with the specified namespace. // Variables named in the vars map will also be replaced with their // corresponding value. func (j *JenkinsRef) ReadJenkinsJobUsingVars(filename, namespace string, vars map[string]string) string { pre := exutil.FixturePath("testdata", "jenkins-plugin", filename) post := exutil.ArtifactPath(filename) if vars == nil { vars = map[string]string{} } vars["PROJECT_NAME"] = namespace err := exutil.VarSubOnFile(pre, post, vars) o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred()) data, err := ioutil.ReadFile(post) o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred()) return string(data) }
g.By(fmt.Sprintf("docker-registry service IP is %s and port %s ", serviceIP, port)) // get the auth so we can pull the build image from the internal docker registry since the builder controller will remove it // from the docker daemon cache when the docker build completes; authCfg, err = exutil.BuildAuthConfiguration(serviceIP+":"+port, oc) // now actually pull the image back in from the openshift internal docker registry fullImageName = authCfg.ServerAddress + "/" + oc.Namespace() + "/" + bldr err = exutil.PullImage(fullImageName, *authCfg) o.Expect(err).NotTo(o.HaveOccurred()) exutil.DumpImage(fullImageName) //update the build configs in the json for the app/lang builds to point to the builder images in the internal docker registry // and then create the build config resources pre := exutil.FixturePath("testdata", "forcepull-test.json") post := exutil.ArtifactPath("forcepull-test.json") varSubDest = authCfg.ServerAddress + "/" + oc.Namespace() // grant access to the custom build strategy g.By("granting system:build-strategy-custom") err = oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "system:build-strategy-custom", oc.Username()).Execute() o.Expect(err).NotTo(o.HaveOccurred()) defer func() { err = oc.AsAdmin().Run("adm").Args("policy", "remove-cluster-role-from-user", "system:build-strategy-custom", oc.Username()).Execute() o.Expect(err).NotTo(o.HaveOccurred()) }() err = exutil.VarSubOnFile(pre, post, varSubSrc, varSubDest) o.Expect(err).NotTo(o.HaveOccurred()) err = exutil.CreateResource(post, oc)