library 'first-class-pipeline'

executeFreeleapsPipeline {
  serviceName = [[ .ServiceName | quote ]]
  environmentSlug = [[ .EnvironmentSlug | quote ]]
  serviceGitBranch = [[ .Spec.Repository.Branch | quote ]]
  serviceGitRepo = [[ .GitRepoURL | quote ]]
  serviceGitRepoType = [[ .Spec.Repository.Type | quote ]]
  serviceGitCredentialsId = [[ .JenkinsGitCredentialsId | quote ]]
  executeMode = [[ .Spec.ContinuousIntegrationSpec.ExecuteMode | quote ]]
  commitMessageLintEnabled = [[ .Spec.ContinuousIntegrationSpec.CommitMessageLintEnabled ]]
  components = [
[[- range $component := .Spec.ContinuousIntegrationSpec.Components ]]  
    [
      name: [[ $component.Name | quote ]],
      root: [[ $component.Root | quote ]],
      language: [[ $component.Language | quote ]],
      dependenciesManager: [[ $component.DependenciesManager | quote ]],
[[- if and (eq $component.DependenciesManager "npm") ($component.NPMPackageJsonFile) ]]
      npmPackageJsonFile: [[ $component.NPMPackageJsonFile | quote ]],
[[- end ]]
[[- if $component.BuildCacheEnabled ]]
      buildCacheEnabled: [[ $component.BuildCacheEnabled ]],
[[- end ]]
    ]
[[- end ]]
  ]
}