Example Scripts for Functions

Updated 5 days ago by Copado Solutions

In this article, you will find some out-of-the-box scripts you can execute as part of a function to complete different tasks.

Before you get to executing advanced scripts, it is a good practice to do a test and ensure you have all the necessary permissions to run a function. You can use the below basic script:

echo hello world $name

If there are any problems, you can troubleshoot them before moving on to running more advanced functions. 

Clone a public Git repository and review its size:

copado -p 'Cloning the repository' 
mkdir repo 
cd repo 
git clone $giturl . 
copado -p 'Running git-sizer'
git-sizer --verbose > git-sizer.txt 
git-sizer --json > git-sizer.json 
copado -p 'Attaching results' 
copado --u git-sizer.txt 
copado --u git-sizer.json

To clone a public repository, you need to add the URL in the Parameters section.

Clone a private repository and review its size:

copado -p 'Cloning the repository' 
mkdir repo 
cd repo 
copado-git-get -d . master git pull 
copado -p 'Running git-sizer' 
git-sizer --verbose > git-sizer.txt 
git-sizer --json > git-sizer.json 
copado -p 'Attaching results' 
copado --u git-sizer.txt 

In the case of a private repository, you need to provide the credentials. To avoid exposing these credentials, use the following dynamic parameter:

{$RecordId.Repository.Credential}

This parameter needs to be sent as a git_json, otherwise, the backend won’t understand it and the copado-git-get command will fail.


How did we do?