# Code C - Nœud de workflow | Docs - nodulz

Source: https://nodulz.com/fr/docs/nodes/script_c

Language: fr

Exécuter du code C personnalisé

## Utilisation et spécificités

La source peut être inline, Git ou un workspace. Le code s’exécute via le runtime conteneur et la cible configurée. L’image, les dépendances et l’accès au dépôt doivent être disponibles sur cette cible.

Type technique : `script_c`. Runtime : `docker`.

## Identifiants et prérequis

Aucun identifiant externe dédié n’est défini par ce nœud. Les sources distantes ou la cible d’exécution peuvent néanmoins nécessiter leurs propres accès.

Consultez le [guide des identifiants](/docs/credentials) si une source distante ou une cible d’exécution nécessite un accès.

## Paramètres

Les noms ci-dessous correspondent aux clés techniques. Les valeurs par défaut ne constituent pas une configuration prête à exécuter : renseignez les champs requis par votre opération. Les chemins contenant [] décrivent les éléments d’une liste ; certains champs dépendent du mode sélectionné.

| Paramètre | Type | Par défaut | Valeurs / limites |
| --- | --- | --- | --- |
| `libraryIds` | `array` | - | -; max 100 |
| `source` | `union` | `{"kind":"inline","script":"#include <stdlib.h>\n#include \"cJSON.h\"\n\ncJSON *run(cJSON *input) {\n  cJSON *out = cJSON_CreateObject();\n  cJSON *trigger = cJSON_GetObjectItemCaseSensitive(input, \"input\");\n  cJSON *upstream = cJSON_GetObjectItemCaseSensitive(input, \"nodes\");\n  // API_TOKEN comes from a selected Secret variables credential.\n  const char *api_token = getenv(\"API_TOKEN\");\n  cJSON_AddItemToObject(out, \"payload\", trigger ? cJSON_Duplicate(trigger, 1) : cJSON_CreateNull());\n  cJSON_AddItemToObject(out, \"upstream\", upstream ? cJSON_Duplicate(upstream, 1) : cJSON_CreateNull());\n  cJSON_AddItemToObject(out, \"hasApiToken\", cJSON_Parse(api_token != NULL && *api_token != 0 ? \"true\" : \"false\"));\n  cJSON_AddItemToObject(out, \"message\", cJSON_CreateString(\"Script output ready\"));\n  return out;\n}\n","dependencies":[]}` | - |
| `source.files` | `record` | - | - |
| `source.directories` | `array` | - | -; max 100 |
| `source.kind` | `literal` | `"inline"` | `inline`, `git`, `workspace` |
| `source.script` | `string` | `"#include <stdlib.h>\n#include \"cJSON.h\"\n\ncJSON *run(cJSON *input) {\n  cJSON *out = cJSON_CreateObject();\n  cJSON *trigger = cJSON_GetObjectItemCaseSensitive(input, \"input\");\n  cJSON *upstream = cJSON_GetObjectItemCaseSensitive(input, \"nodes\");\n  // API_TOKEN comes from a selected Secret variables credential.\n  const char *api_token = getenv(\"API_TOKEN\");\n  cJSON_AddItemToObject(out, \"payload\", trigger ? cJSON_Duplicate(trigger, 1) : cJSON_CreateNull());\n  cJSON_AddItemToObject(out, \"upstream\", upstream ? cJSON_Duplicate(upstream, 1) : cJSON_CreateNull());\n  cJSON_AddItemToObject(out, \"hasApiToken\", cJSON_Parse(api_token != NULL && *api_token != 0 ? \"true\" : \"false\"));\n  cJSON_AddItemToObject(out, \"message\", cJSON_CreateString(\"Script output ready\"));\n  return out;\n}\n"` | - |
| `source.dependencies` | `array` | `[]` | - |
| `source.repo` | `string` | - | -; min 1 |
| `source.branch` | `string` | `"main"` | -; min 1 |
| `source.scriptPath` | `string` | - | -; min 1 |
| `source.credentialId` | `string` | - | - |
| `source.installRoot` | `string` | - | - |
| `source.installCommand` | `string` | - | - |
| `source.workingDir` | `string` | - | - |
| `image` | `string` | - | - |
| `workspaceSource` | `union` | - | - |
| `workspaceSource.kind` | `literal` | - | `upstream`, `node` |
| `workspaceSource.key` | `string` | - | -; min 1 |
| `executionTarget` | `union` | `{"kind":"host"}` | - |
| `executionTarget.kind` | `literal` | `"host"` | `aws_ecs`, `aws_lambda`, `gcp_job`, `gcp_function`, `azure_container`, `azure_function`, `scaleway_job`, `scaleway_function`, `scaleway_container`, `digitalocean_function`, `host`, `remote_server`, `kube`, `swarm` |
| `executionTarget.credentialId` | `string` | - | -; min 1, max 512 |
| `executionTarget.storageCredentialId` | `string` | - | -; min 1, max 512 |
| `executionTarget.bucket` | `string` | - | - |
| `executionTarget.region` | `string` | - | `fr-par`, `nl-ams`, `pl-waw`; max 64 |
| `executionTarget.cluster` | `string` | - | -; min 1, max 512 |
| `executionTarget.taskDefinition` | `string` | - | -; min 1, max 512 |
| `executionTarget.containerName` | `string` | - | -; max 100 |
| `executionTarget.subnets` | `array` | - | -; min 1, max 16 |
| `executionTarget.securityGroups` | `array` | `[]` | -; max 5 |
| `executionTarget.assignPublicIp` | `boolean` | `false` | - |
| `executionTarget.functionName` | `string` | - | -; min 1, max 256 |
| `executionTarget.project` | `string` | - | -; max 100 |
| `executionTarget.jobName` | `string` | - | -; max 100 |
| `executionTarget.endpoint` | `string` | - | -; max 512 |
| `executionTarget.subscriptionId` | `string` | - | - |
| `executionTarget.resourceGroup` | `string` | - | -; max 90 |
| `executionTarget.functionApp` | `string` | - | -; max 100 |
| `executionTarget.jobId` | `string` | - | - |
| `executionTarget.functionId` | `string` | - | - |
| `executionTarget.containerId` | `string` | - | - |
| `executionTarget.namespaceId` | `string` | - | - |
| `executionTarget.serverId` | `string` | - | -; min 1 |
| `executionTarget.provider` | `enum` | - | `aws`, `gcp`, `scaleway`, `ovh`, `azure`, `digitalocean`, `hetzner` |
| `executionTarget.clusterId` | `string` | - | -; min 1 |
| `executionTarget.namespace` | `string` | - | - |
| `secretCredentialIds` | `array` | `[]` | - |

## Aide de configuration

| Réglage | Rôle et conseils |
| --- | --- |
| `image`<br>Image de conteneur | Image utilisée pour exécuter le script (ex. docker.io/library/node:22-bookworm). Pour une image Podman locale, utiliser localhost/nom:tag. |
| `secretCredentialIds`<br>Secrets | Connexions Secrets injectées comme variables d'environnement du script (process.env, os.environ…). Le fichier qui les porte est effacé dès le démarrage du conteneur. |

## Configuration initiale

Exemple de configuration initiale du catalogue, à adapter avant exécution. Les secrets doivent rester dans les identifiants.

```json
{
  "source": {
    "kind": "inline",
    "script": "#include <stdlib.h>\n#include \"cJSON.h\"\n\ncJSON *run(cJSON *input) {\n  cJSON *out = cJSON_CreateObject();\n  cJSON *trigger = cJSON_GetObjectItemCaseSensitive(input, \"input\");\n  cJSON *upstream = cJSON_GetObjectItemCaseSensitive(input, \"nodes\");\n  // API_TOKEN comes from a selected Secret variables credential.\n  const char *api_token = getenv(\"API_TOKEN\");\n  cJSON_AddItemToObject(out, \"payload\", trigger ? cJSON_Duplicate(trigger, 1) : cJSON_CreateNull());\n  cJSON_AddItemToObject(out, \"upstream\", upstream ? cJSON_Duplicate(upstream, 1) : cJSON_CreateNull());\n  cJSON_AddItemToObject(out, \"hasApiToken\", cJSON_Parse(api_token != NULL && *api_token != 0 ? \"true\" : \"false\"));\n  cJSON_AddItemToObject(out, \"message\", cJSON_CreateString(\"Script output ready\"));\n  return out;\n}\n",
    "dependencies": []
  },
  "executionTarget": {
    "kind": "host"
  }
}
```

## Vérification

Testez le nœud avec des données représentatives. Contrôlez sa sortie dans l’inspecteur et les logs, puis utilisez le mapping de l’éditeur pour les champs des nœuds suivants. Un test de déclencheur avec payload simulé ne valide pas la livraison du service externe.

Voir aussi : [Expressions et données](/docs/expressions), [Exécutions](/docs/executions), [Catalogue des nœuds](/docs/nodes).

## Pour aller plus loin

- [Fonctionnalités - nodulz](https://nodulz.com/fr/product/overview)
- [Catalogue des nœuds - nodulz](https://nodulz.com/fr/product/catalog)
- [Serveur MCP - nodulz](https://nodulz.com/fr/product/mcp)
- [Tarifs - nodulz](https://nodulz.com/fr/pricing)
- [Cas d’usage et automatisations - nodulz](https://nodulz.com/fr/use-cases)
- [Choisissez ce que vos workflows peuvent faire. - nodulz](https://nodulz.com/fr/compare)
- [Documentation - nodulz](https://nodulz.com/fr/docs)
