# Executing a custom script on your projects

Talend CI Builder allows you to execute a custom script on your projects using the mvn org.talend.ci:builder-maven-plugin:8.0.X:executeScript and -DexecuteRawScript=true/false commands.

## Before you begin

## About this task

To execute a custom script on your projects:

## Procedure

Run the mvn org.talend.ci:builder-maven-plugin:8.0.X:executeScript command along with the -DscriptFile and the -DexecuteRawScript=true/false commands under the directory where your projects have been checked out.

Pay attention to the following before executing the script on your projects:

* If -DexecuteRawScript=false (default):

  * the connection to every project available in the workspace is established automatically.
  * the createProject command is executed inside the workspace and declares all the projects detected in the workspace.
  * the CI-CommandLine instance then executes the customer script on all projects detected in your workspace unless you have filtered your projects using the -DprojectFilter parameter.

  Example:

  ```
  # The content of the script named importFile.txt
  importItems /home/talend/Patch_dynamic_issue.zip
  regenerateAllPoms
  ```

  ```
  # To execute the importFile.txt custom script 
  mvn org.talend.ci:builder-maven-plugin:<version>:executeScript 
  -Dlicense.path=/home/talend/studio/license 
  <!-- This parameter is only supported and needed for users with Talend Studio 8.0.1 R2024-04 or lower
  -Dtalend.studio.p2.base=https://update.talend.com/Studio/8/base -->
  -Dtalend.studio.p2.update=https://update.talend.com/Studio/8/updates/R2023-01  
  -DscriptFile=D:/importFile.txt 
  ```

  This script will then be executed on all detected projects (here, TALEND\_CI\_1 and TALEND\_CI\_2). This script calls the importItems command to import an archive file and the regenerateAllPoms command to regenerate POM files for your projects:

  ```
  initLocal
  logonProject -pn 'TALEND_CI_1' -ul 'jobbuilder@talend.com' -gt 
  importItems /home/talend/Patch_dynamic_issue.zip -o 
  regenerateAllPoms
  logoffProject
  logonProject -pn 'TALEND_CI_2' -ul 'jobbuilder@talend.com' -gt 
  importItems /home/talend/Patch_dynamic_issue.zip -o regenerateAllPoms
  logoffProject
  ```

* If -DexecuteRawScript=true:

  * the script only executes the stated commands once.
  * the connection to projects is not established automatically and dedicated parameters need to be declared manually (initLocal, createProject, logonProject and logoffProject).

  Example:

  ```
  # The content of the script named importFile.txt
  initLocal
  logonProject -pn 'TALEND_CI_1' -ul 'jobbuilder@talend.com' -gt 
  importItems /home/talend/Patch_dynamic_issue.zip -o 
  regenerateAllPoms
  logoffProject
  ```

  ```
  # To execute the importFile.txt custom script 
  mvn org.talend.ci:builder-maven-plugin:<version>:executeScript 
  -DexecuteRawscript=true
  -Dlicense.path=/home/talend/studio/license 
  <!-- This parameter is only supported and needed for users with Talend Studio 8.0.1 R2024-04 or lower
  -Dtalend.studio.p2.base=https://update.talend.com/Studio/8/base -->
  -Dtalend.studio.p2.update=https://update.talend.com/Studio/8/updates/R2023-01  
  -DscriptFile=d:/importFile.txt 
  ```

  This script will be executed according to the exact commands declared previously. This script calls the importItems command to import an archive file and the regenerateAllPoms command to regenerate the POM files for your TALEND\_CI\_1 project:

  ```
  initLocal
  logonProject -pn 'TALEND_CI_1' -ul 'jobbuilder@talend.com' -gt 
  importItems /home/talend/Patch_dynamic_issue.zip -o 
  regenerateAllPoms
  logoffProject
  ```

For more information about CI related parameters, see [CI builder-related Maven parameters](https://help.qlik.com/talend/en-US/software-dev-lifecycle-best-practices-guide/8.0/cibuilder-maven-build-options).

For more information about Talend CommandLine, see [Talend CommandLine API](https://help.qlik.com/talend/en-US/software-dev-lifecycle-best-practices-guide/8.0/cmdl-api "The exhaustive help for all commands that you get when you type the -help command in your Talend CommandLine application.").