<commit_before>+++
title = "Script"
chapter = true

[menu.main]
parent = "actions-builtin"
identifier = "script"

+++

**Script** is a builtin action, you can't modify it.

This action execute a script, written in script attribute

## Parameters

* script: Content of your script. You can put

```bash
#!/bin/bash
```

 or

```bash
#!/bin/perl
```

 at first line.

Make sure that the binary used is in the pre-requisites of action

#### Variable

You can use [CDS Variables]({{< relref "building-pipelines.variables.md" >}}) in a step script.

![img](/images/building-pipelines.actions.builtin.script-bash.png)

### Example

* Job Configuration, a step with perl, another with bash

![img](/images/building-pipelines.actions.builtin.script-job.png)

* Launch pipeline, check logs

![img](/images/building-pipelines.actions.builtin.script-logs.png)
<commit_msg>doc (action): builtin script - set -e (#1046)<commit_after>+++
title = "Script"
chapter = true

[menu.main]
parent = "actions-builtin"
identifier = "script"

+++

**Script** is a builtin action, you can't modify it.

This action execute a script, written in script attribute

## Parameters

* script: Content of your script. You can put

```bash
#!/bin/bash
```

 or

```bash
#!/bin/perl
```

 at first line.

Make sure that the binary used is in the pre-requisites of action.

If you use a shebang bash, sh, zsh or ksh, CDS will return a failure on your step if an executed command fails.

If you want to control command's exit code, you have to add
```bash
set +e
```

Example of step, CDS will exit at the first line, as `which a-unknown-binary will return an error` :

```bash
which a-unknown-binary # Step will fail here, lines below won't be executed
if [ $? -ne 0 ]; then
  echo "binary a-unknown-binary does not exists";
  exit 1
fi;
exit 0
```

Example of step, CDS will execute all lines:

```bash
set +e
which a-unknown-binary
if [ $? -ne 0 ]; then
  echo "binary a-unknown-binary does not exists"; # this will be displayed
  exit 1
fi;
exit 0
```


#### Variable

You can use [CDS Variables]({{< relref "building-pipelines.variables.md" >}}) in a step script.

![img](/images/building-pipelines.actions.builtin.script-bash.png)

### Example

* Job Configuration, a step with perl, another with bash

![img](/images/building-pipelines.actions.builtin.script-job.png)

* Launch pipeline, check logs

![img](/images/building-pipelines.actions.builtin.script-logs.png)

{'fraction_non_alphanumeric': 0.13371616078753076, 'fraction_numerical': 0.004101722723543888, 'mean_word_length': 4.049689440993789, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2373029', 'n_tokens_mistral': 846, 'n_tokens_neox': 780, 'n_words': 292}