{"id":10646,"library":"codefresh","title":"Codefresh CLI","description":"The `codefresh` package provides the official command-line interface (CLI) for interacting with the Codefresh platform, enabling users to manage CI/CD pipelines, deployments, and various resources directly from their terminal. It supports a wide array of operations including managing builds, images, tags, authentication contexts, and Helm releases. The current stable version is 1.1.3. Releases appear to be frequent, often weekly or bi-weekly, addressing bugs, security updates, and new features. Its primary differentiator is providing a comprehensive, scriptable interface to Codefresh's full suite of CI/CD capabilities, serving as a powerful tool for automation and integration within development workflows. It requires Node.js v24.0.0 or higher to run.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/codefresh-io/cli","tags":["javascript","command line"],"install":[{"cmd":"npm install codefresh","lang":"bash","label":"npm"},{"cmd":"yarn add codefresh","lang":"bash","label":"yarn"},{"cmd":"pnpm add codefresh","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The `codefresh` package is primarily a command-line interface. For programmatic interaction in JavaScript/TypeScript, it's typically invoked as a child process using tools like `execa` or Node.js's built-in `child_process` module. Direct `import` or `require` of its internal modules is not officially supported or recommended for external use.","symbol":"CLI Execution","correct":"import { execa } from 'execa'; await execa('codefresh', ['version']);"},{"note":"When installed globally (`npm install -g codefresh`), the `codefresh` executable is added to the system's PATH. When installed locally (e.g., as a development dependency), its executable is located in `node_modules/.bin/codefresh`.","symbol":"Executable Path","correct":"import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; const __dirname = dirname(fileURLToPath(import.meta.url)); const cliPath = join(__dirname, 'node_modules', '.bin', 'codefresh');"},{"note":"The `codefresh` package is not designed to be imported as a standard JavaScript/TypeScript library. Its functionality is exposed exclusively via the command-line interface, and attempts to import functions or objects directly will fail.","wrong":"import { getBuilds } from 'codefresh'; // This is not an exposed library API.","symbol":"Library Import (Discouraged)"}],"quickstart":{"code":"import { execa } from 'execa'; // npm install execa\n\nasync function setupAndUseCodefreshCLI() {\n  console.log('--- Installing Codefresh CLI globally ---\\n');\n  try {\n    await execa('npm', ['install', '-g', 'codefresh'], { stdio: 'inherit' });\n    console.log('\\nCodefresh CLI installed successfully.\\n');\n  } catch (error) {\n    console.error('Failed to install Codefresh CLI:', error.message);\n    return;\n  }\n\n  const apiKey = process.env.CODEFRESH_API_KEY ?? '';\n  if (!apiKey) {\n    console.error('CODEFRESH_API_KEY environment variable is not set. Please generate an API key from Codefresh account settings and set it.\\n');\n    return;\n  }\n\n  console.log('--- Authenticating with Codefresh CLI ---\\n');\n  try {\n    await execa('codefresh', ['auth', 'create-context', '--api-key', apiKey], { stdio: 'inherit' });\n    console.log('\\nAuthentication successful. Context created.\\n');\n  } catch (error) {\n    console.error('Authentication failed. Check your API key and network connection:', error.message);\n    return;\n  }\n\n  console.log('--- Getting Codefresh CLI version ---\\n');\n  try {\n    const { stdout } = await execa('codefresh', ['version']);\n    console.log(`Codefresh CLI Version: ${stdout.trim()}\\n`);\n  } catch (error) {\n    console.error('Failed to get CLI version:', error.message);\n  }\n\n  console.log('--- Listing Codefresh contexts (example) ---\\n');\n  try {\n    const { stdout } = await execa('codefresh', ['get', 'contexts']);\n    console.log('Codefresh Contexts:\\n', stdout);\n  } catch (error) {\n    console.error('Failed to list contexts:', error.message);\n  }\n}\n\nsetupAndUseCodefreshCLI();","lang":"typescript","description":"Demonstrates global installation of the Codefresh CLI, authentication using an API key from environment variables, and fetching the CLI version and configured contexts programmatically."},"warnings":[{"fix":"Upgrade your Node.js installation to version 24.0.0 or newer (e.g., using `nvm install 24 && nvm use 24`).","message":"The `codefresh` CLI now explicitly requires Node.js version 24.0.0 or higher. Running with older Node.js versions will result in an error and prevents the CLI from functioning.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"It is highly recommended to upgrade to the latest stable version of the `codefresh` CLI immediately to ensure security (`npm install -g codefresh@latest`).","message":"Multiple security vulnerabilities were addressed in recent releases, including fixes for supply chain issues and updated dependencies. Older versions may contain known security flaws.","severity":"breaking","affected_versions":"<1.0.6"},{"fix":"Interact with the CLI by executing `codefresh` commands as a child process from your JavaScript/TypeScript code (e.g., using Node.js `child_process` or a library like `execa`).","message":"The `codefresh` package is a command-line interface tool, not a JavaScript library. It is not designed for direct programmatic import (`import {} from 'codefresh'`). Its functionality is exposed via shell commands.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use environment variables (e.g., `process.env.CODEFRESH_API_KEY`) or secure secret management systems to provide API keys to the CLI, especially in CI/CD environments.","message":"Authentication with the Codefresh CLI relies on API keys. Storing API keys directly in source code or committing them to version control poses a significant security risk.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.1.3':56 'address':68 'appear':58 'array':38 'authent':46 'autom':98 'bi':66 'bi-week':65 'bug':69 'build':43 'capabl':91 'ci/cd':24,90 'cli':2,13 'codefresh':1,4,18,85 'command':10,113 'command-lin':9 'comprehens':81 'context':47 'current':52 'deploy':26 'develop':102 'differenti':77 'direct':30 'enabl':20 'featur':74 'frequent':61 'full':87 'helm':49 'higher':109 'imag':44 'includ':41 'integr':100 'interact':15 'interfac':12,83 'javascript':112 'line':11,114 'manag':23,42 'new':73 'node.js':106 'offici':8 'often':62 'oper':40 'packag':5 'pipelin':25 'platform':19 'power':95 'primari':76 'provid':6,79 'releas':50,57 'requir':105 'resourc':29 'run':111 'scriptabl':82 'secur':70 'serv':92 'stabl':53 'suit':88 'support':35 'tag':45 'termin':33 'tool':96 'updat':71 'user':21 'v24.0.0':107 'various':28 'version':54 'week':63,67 'wide':37 'within':101 'workflow':103","created_at":"2026-04-19T13:33:53.772750+00:00","updated_at":"2026-04-19T13:33:53.772750+00:00","problems":[{"fix":"Install the CLI globally using npm: `npm install -g codefresh`.","cause":"The Codefresh CLI is not installed globally or is not available in your system's PATH.","error":"codefresh: command not found"},{"fix":"Generate a new API key from your Codefresh account settings and ensure it is correctly provided: `codefresh auth create-context --api-key {{YOUR_API_KEY}}`.","cause":"The provided API key during `codefresh auth create-context` is incorrect, expired, or was not set.","error":"Error: API key is missing or invalid. Please generate one from your Codefresh account settings."},{"fix":"Upgrade your Node.js installation to version 24.0.0 or higher. Tools like `nvm` (Node Version Manager) can help manage multiple Node.js versions.","cause":"You are attempting to run the Codefresh CLI with an unsupported, older version of Node.js.","error":"Error: Minimum Node.js version 24.0.0 is required. Detected version X.Y.Z"},{"fix":"The `codefresh` package is a CLI tool. Do not import it directly. Instead, execute its commands via `child_process.spawn` or `execa` for programmatic interaction.","cause":"Attempting to `import` or `require` the `codefresh` package as a regular JavaScript library.","error":"Cannot find module 'codefresh' or 'codefresh/lib/some_module'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"codefresh","cli_version":null,"type":"library","homepage":"https://codefresh.io","github":"https://github.com/codefresh-io/cli","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/codefresh","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","aws","gcp","azure"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}