diff --git a/dsl/procedures/exportDslToGit/form.xml b/dsl/procedures/exportDslToGit/form.xml new file mode 100644 index 00000000..c37a8177 --- /dev/null +++ b/dsl/procedures/exportDslToGit/form.xml @@ -0,0 +1,254 @@ + + + + entry + + rsrcName + 1 + local + The resource where the DSL files will be checked out from git and imported to the Flow server. The directory on this resource must be accessible from the Flow server. + + + entry + + dest + 1 + The directory on the resource where the source tree will be created and from where the DSL files are read to be imported in Flow server. This directory must be accessible from the Flow server. In a clustered deployment, all Flow server nodes must have access to this directory. + + + checkbox + + cleanup + 1 + 0 + 0 + This option will delete the destination directory with the source tree after the job execution. + 0 + + + checkbox + + clone + 1 + 0 + 0 + This option will clone a repository into a newly created directory. + 0 + + + + checkbox + + GitOverwrite + 1 + 0 + 0 + This option will overwrite a repository if it already exists. + 0 + + + entry + + gitConfig + The name of a saved Git configuration. + 1 + 1 + + + entry + + repoUrl + URL to the repository to pull from. ie: 'git://server/repo.git'. + 1 + + + + entry + + branch + The name of the Git branch to use. ie: 'experimental'. + 0 + + + + entry + + objectType + 1 + Object type to generate DSL for. + + + entry + + objectName + 1 + Object name to generate DSL for. + + + textarea + files + 1 + Files pattern (GLOB) to use to add files to the commit. Each pattern per line. + + .> + + + textarea + message + 0 + Commit message for the newly created commit. If not provided, date and CloudBees CD Job ID will be used to identify the commit. + + + + entry + committerName + 1 + Name of the committer (someone who has committed the code as opposed to the author). + + + + entry + committerEmail + 1 + Email of the committer. + + + + checkbox + removeMissing + If checked, the files that are missing from the repository will be removed from SCM. + + 1 + 0 + 0 + + + checkbox + failOnEmptyCommit + If checked, the procedure will fail if there is nothing to commit. + + 1 + 0 + 0 + + + + checkbox + + suppressNulls + 0 + 1 + 0 + 1 + Exclude from the generated DSL properties with null value. + + + + checkbox + + suppressDefaults + 0 + 1 + 0 + 0 + Exclude from the generated DSL properties with default value. + + + + checkbox + + suppressParent + 0 + 1 + 0 + 0 + Exclude from the generated DSL properties referred to object parent. + + + + checkbox + + includeAcls + 0 + 1 + 0 + 0 + Include in ACLs for objects. + + + + checkbox + + includeAclsInDifferentFile + 0 + 1 + 0 + 0 + Include ACLs for generated objects in different file. + + + + checkbox + + includeAllChildren + 0 + 1 + 0 + 0 + Include in the generated DSL all object children. If True - ignore value of 'Include Children' parameter. + + + + textarea + + includeChildren + 0 + Comma-separated list of object children the DSL should be generated for. + + + + checkbox + + includeChildrenInSameFile + 0 + 1 + 0 + 0 + Include in the generated DSL all object children. If True - ignore value of 'Include Children' parameter. + + + + textarea + + childrenInDifferentFile + 0 + Comma-separated list of patterns to include, like pipelines, procedures.*, applications.applicationTiers.components + + + + entry + + tag + Provide the name of a specific tag to checkout after the clone command. + 0 + clone + ${clone} == "1" + + + diff --git a/dsl/procedures/exportDslToGit/procedure.dsl b/dsl/procedures/exportDslToGit/procedure.dsl new file mode 100644 index 00000000..1e4bbc8c --- /dev/null +++ b/dsl/procedures/exportDslToGit/procedure.dsl @@ -0,0 +1,80 @@ +import java.io.File + +def procName = 'exportDslToGit' +procedure procName, { + jobNameTemplate = 'export-dsl-to-git-$[jobId]' + + step 'Clone', + subprocedure: 'Clone', + subproject: '/plugins/EC-Git/project', + condition: '$[/myJob/actualParameters/clone]', + errorHandling:'abortProcedure', + resourceName: '$[rsrcName]', + actualParameter: [ + branch: '$[branch]', + config: '$[gitConfig]', + gitRepoFolder: '$[dest]', + overwrite: '$[GitOverwrite]', + repoUrl: '$[repoUrl]', + tag: '$[tag]' + ] + + step 'Pull', + subprocedure: 'Pull', + subproject: '/plugins/EC-Git/project', + resourceName: '$[rsrcName]', + errorHandling: 'abortProcedure', + actualParameter: [ + branch: '$[branch]', + config: '$[gitConfig]', + gitRepoFolder: '$[dest]', + repoUrl: '$[repoUrl]', + ] + + step 'generateDslToDirectory', + subprocedure: 'generateDslToDirectory', + errorHandling: 'abortProcedure', + actualParameter: [ + directory: '$[dest]', + objectType: '$[objectType]', + objectName: '$[objectName]', + pool: '$[rsrcName]', + suppressNulls: '$[suppressNulls]', + suppressDefaults: '$[suppressDefaults]', + suppressParent: '$[suppressParent]', + includeAcls: '$[includeAcls]', + includeAclsInDifferentFile: '$[includeAclsInDifferentFile]', + includeAllChildren: '$[includeAllChildren]', + includeChildren: '$[includeChildren]', + includeChildrenInSameFile: '$[includeChildrenInSameFile]', + childrenInDifferentFile: '$[childrenInDifferentFile]' + ] + + step 'exportDslToGit', + subprocedure: 'Commit', + subproject:'/plugins/EC-Git/project', + resourceName: '$[rsrcName]', + errorHandling: 'abortProcedure', + actualParameter: [ + committerEmail: '$[committerEmail]', + committerName: '$[committerName]', + config: '$[gitConfig]', + failOnEmptyCommit: '$[failOnEmptyCommit]', + files: '$[files]', + gitRepoFolder: '$[dest]', + message: '$[message]', + push: 'true', + removeMissing: '$[removeMissing]' + ] + + step 'cleanup', { + condition = '''$[/javascript + var cleanup= \'$[cleanup]\'; + (cleanup== \'true\' || cleanup== \'1\') ; + ]''' + alwaysRun = '1' + command = new File(pluginDir, "dsl/procedures/$procName/steps/cleanup.groovy").text + resourceName = '$[rsrcName]' + shell = 'ec-groovy' + } +} \ No newline at end of file diff --git a/dsl/procedures/exportDslToGit/steps/cleanup.groovy b/dsl/procedures/exportDslToGit/steps/cleanup.groovy new file mode 100644 index 00000000..7e021ad0 --- /dev/null +++ b/dsl/procedures/exportDslToGit/steps/cleanup.groovy @@ -0,0 +1 @@ +new File("$[dest]").deleteDir() \ No newline at end of file diff --git a/dsl/procedures/importDslFromGit/form.xml b/dsl/procedures/importDslFromGit/form.xml index a1ac986f..4bde9726 100644 --- a/dsl/procedures/importDslFromGit/form.xml +++ b/dsl/procedures/importDslFromGit/form.xml @@ -44,7 +44,7 @@ checkbox - + overwrite 0 1 @@ -54,16 +54,16 @@ entry - - config + + gitConfig The name of a saved SCM configuration. 1 1 entry - - GitRepo + + repoUrl URL to the repository to pull from. ie: 'git://server/repo.git'. 1 @@ -77,8 +77,9 @@ entry - - GitBranch + + branch + master The name of the Git branch to use. ie: 'experimental'. 0 diff --git a/dsl/procedures/importDslFromGit/procedure.dsl b/dsl/procedures/importDslFromGit/procedure.dsl index 46bbeba6..92e89b82 100644 --- a/dsl/procedures/importDslFromGit/procedure.dsl +++ b/dsl/procedures/importDslFromGit/procedure.dsl @@ -4,22 +4,35 @@ def procName = 'importDslFromGit' procedure procName, { jobNameTemplate = 'import-dsl-from-git-$[jobId]' - step 'checkoutDsl', - subprocedure: 'CheckoutCode', - subproject:'/plugins/ECSCM-Git/project', + step 'Clone', + subprocedure: 'Clone', + subproject: '/plugins/EC-Git/project', + condition: '$[/myJob/actualParameters/clone]', resourceName: '$[rsrcName]', errorHandling: 'abortProcedure', actualParameter: [ - clone: '$[clone]', + branch: '$[branch]', commit: '$[commit]', - config: '$[config]', + config: '$[gitConfig]', depth: '$[depth]', - dest: '$[dest]', - GitBranch: '$[GitBranch]', - GitRepo: '$[GitRepo]', + gitRepoFolder: '$[dest]', overwrite: '$[GitOverwrite]', + repoUrl: '$[repoUrl]', tag: '$[tag]' - ] + ] + + step 'Pull', + subprocedure: 'Pull', + subproject: '/plugins/EC-Git/project', + resourceName: '$[rsrcName]', + errorHandling: 'abortProcedure', + actualParameter: [ + branch: '$[branch]', + config: '$[gitConfig]', + gitRepoFolder: '$[dest]', + repoUrl: '$[repoUrl]', + ] + step 'installFromDirectory', subprocedure: 'installDslFromDirectory',