diff --git a/example/freestyle.xml b/example/freestyle.xml index 0f35857..affe919 100644 --- a/example/freestyle.xml +++ b/example/freestyle.xml @@ -1,4 +1,4 @@ - + {{ .Parameters.description }} false diff --git a/example/pipeline.xml b/example/pipeline.xml index 562302a..7b17c9c 100644 --- a/example/pipeline.xml +++ b/example/pipeline.xml @@ -1,4 +1,4 @@ - + {{ .Parameters.description }} false diff --git a/jenkins/data_source_jenkins_job_test.go b/jenkins/data_source_jenkins_job_test.go index a499c2b..c7f0250 100644 --- a/jenkins/data_source_jenkins_job_test.go +++ b/jenkins/data_source_jenkins_job_test.go @@ -19,20 +19,20 @@ func TestAccJenkinsJobDataSource_basic(t *testing.T) { Steps: []resource.TestStep{ { Config: fmt.Sprintf(` - resource jenkins_job foo { - name = "tf-acc-test-%s" - template = < + {{ .Parameters.description }} false diff --git a/jenkins/template.go b/jenkins/template.go index 91be1ca..c0c5c34 100644 --- a/jenkins/template.go +++ b/jenkins/template.go @@ -2,8 +2,8 @@ package jenkins import ( "bytes" - "html/template" "log" + "text/template" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/jenkins/util.go b/jenkins/util.go index 754a37d..3ebd3ec 100644 --- a/jenkins/util.go +++ b/jenkins/util.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log" + "regexp" "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -78,10 +79,11 @@ func templateDiff(k, old, new string, d *schema.ResourceData) bool { new, _ = renderTemplate(new, d) // Sanitize the XML entries to prevent inadvertent inequalities - old = strings.Replace(old, "", "", -1) + re := regexp.MustCompile(`<\?xml.+\?>`) + old = re.ReplaceAllString(old, "") old = strings.Replace(old, " ", "", -1) old = strings.TrimSpace(old) - new = strings.Replace(new, "", "", -1) + new = re.ReplaceAllString(new, "") new = strings.Replace(new, " ", "", -1) new = strings.TrimSpace(new)