Skip to main content

Custom Script from Git

You can use Custom Script from Git to clone and run your own scripts directly from a Git repository as part of your Appcircle build. This step supports authenticated cloning (via username and PAT).

Before execution, the step will clone (or reuse) your repository, check out the specified branch, and execute the script based on its file extension (postfix).

If the AC_SCRIPT_FILENAME value includes a relative path (for example, folder/test.sh), the script will be located and executed from that path within the repository structure.

info

The step inspects your script file’s postfix (its extension—.sh, .py, .rb, .pl, .js, .java) to choose the execution path. It must match exactly. Supported script types and their execution commands:

  • example-script.sh → bash
  • example_script.rb → ruby
  • example_script.py → python
  • example-script.pl → perl
  • example-script.js → nodejs
  • ExampleScript.java → java
danger

When executing a Java file, the script filename and the class name within the script must match.

javac ExampleScript.java
java ExampleScript
caution

If you are seeing the following error in the build log, please ensure that both the username and the personal access token (PAT) are set correctly. This error is returned by the Git provider when authentication fails due to an incorrect or missing username or PAT:


fatal: could not read Username for Git provider

Prerequisites

There are no prerequisites required before using the Custom Script from Git step.

tip

Note that you can put the Custom Script from Git component anywhere you want in the workflow. This step is used to add different capabilities to the existing workflow. As well as the Custom Script.

Screenshot

Input Variables

This step contains some input variable(s). It needs these variable(s) to work. The table below gives explanation for this variable(s).

Sensitive Variables

Please do not use sensitive variables such as Username, Password, API Key, or Personal Access Key directly within the step.

We recommend using Environment Variables groups for such sensitive variables.

Screenshot
Variable NameDescriptionStatus
$AC_SCRIPT_FILENAMESpecifies the exact name of the script file to execute within the Git repository (e.g., test.sh, code.rb or relative_path/python.py).Required
$AC_SCRIPT_EXTRA_PARAMETERSAdditional parameters to pass to the script (comma "," separated; if a parameter has an empty character, define it with " "; e.g. param1,param2,"param3 with spaces",param4).Optional
$AC_SCRIPT_REPO_DIRIf the Git repository has already been cloned in a previous step of the same workflow, set the Repository Directory Output here. This input is required if AC_SCRIPT_REPO_CLONE_URL is not provided.Optional
$AC_SCRIPT_REPO_CLONE_URLGit repository clone URL. Required if the Repository Directory Output is not provided. (e.g.
examplegit.examplerepo.git
No description available
examplegit.examplerepo.git
Preview of examplegit.examplerepo.git
). This input is required if AC_SCRIPT_REPO_DIR is not provided.
Optional
$AC_SCRIPT_GIT_USERNAMEGit provider username for authentication. This is required if the AC_SCRIPT_REPO_DIR input is not provided and the Git repository is private.Optional
$AC_SCRIPT_GIT_PATGit provider personal access token for authentication. This is required if the AC_SCRIPT_REPO_DIR input is not provided and the Git repository is private.Optional
$AC_SCRIPT_GIT_BRANCHName of the branch to check out from the script repository. If not specified, the repository's default branch will be used.Optional

Output Variables

The output(s) resulting from the operation of this component are as follows:

Screenshot
Variable NameDescription
AC_SCRIPT_REPO_OUTPUT_DIRThe directory path where the custom script repository is located on the runner. This output can be reused in subsequent workflow steps.

To access the source code of this component, please use the following link:

Preview of GitHub - appcircleio/appcircle-custom-script-from-git-component