diff --git a/docs/docs/integrations/providers/jenkins.mdx b/docs/docs/integrations/providers/jenkins.mdx new file mode 100644 index 00000000000..45e217d2422 --- /dev/null +++ b/docs/docs/integrations/providers/jenkins.mdx @@ -0,0 +1,17 @@ +# Jenkins + +[Jenkins](https://www.jenkins.io/) is an open-source automation platform that enables +software teams to streamline their development workflows. It's widely adopted in the +DevOps community as a tool for automating the building, testing, and deployment of +applications through CI/CD pipelines. + + +## Installation and Setup + +```bash +pip install langchain-jenkins +``` + +## Tools + +See detail on available tools [here](/docs/integrations/tools/jenkins). diff --git a/docs/docs/integrations/tools/jenkins.ipynb b/docs/docs/integrations/tools/jenkins.ipynb new file mode 100644 index 00000000000..c8fdd05b40f --- /dev/null +++ b/docs/docs/integrations/tools/jenkins.ipynb @@ -0,0 +1,225 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Jenkins\n", + "\n", + "Tools for interacting with [Jenkins](https://www.jenkins.io/).\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Overview\n", + "\n", + "The `langchain-jenkins` package allows you to execute and control CI/CD pipelines with\n", + "Jenkins." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Setup\n", + "\n", + "Install `langchain-jenkins`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "shellscript" + } + }, + "outputs": [], + "source": [ + "%pip install --upgrade --quiet langchain-jenkins" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Credentials\n", + "\n", + "You'll need to setup or obtain authorization to access Jenkins server." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "shellscript" + } + }, + "outputs": [], + "source": [ + "import getpass\n", + "import os\n", + "\n", + "\n", + "def _set_env(var: str):\n", + " if not os.environ.get(var):\n", + " os.environ[var] = getpass.getpass(f\"{var}: \")\n", + "\n", + "\n", + "_set_env(\"PASSWORD\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Instantiation\n", + "To disable the SSL Verify, set `os.environ[\"PYTHONHTTPSVERIFY\"] = \"0\"`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from langchain_jenkins import JenkinsAPIWrapper, JenkinsJobRun\n", + "\n", + "tools = [\n", + " JenkinsJobRun(\n", + " api_wrapper=JenkinsAPIWrapper(\n", + " jenkins_server=\"https://example.com\",\n", + " username=\"admin\",\n", + " password=os.environ[\"PASSWORD\"],\n", + " )\n", + " )\n", + "]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Invocation\n", + "You can now call invoke and pass arguments." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1. Create the Jenkins job" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "jenkins_job_content = \"\"\n", + "src_file = \"job1.xml\"\n", + "with open(src_file) as fread:\n", + " jenkins_job_content = fread.read()\n", + "tools[0].invoke({\"job\": \"job01\", \"config_xml\": jenkins_job_content, \"action\": \"create\"})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "2. Run the Jenkins Job" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "tools[0].invoke({\"job\": \"job01\", \"parameters\": {}, \"action\": \"run\"})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "3. Get job info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "resp = tools[0].invoke({\"job\": \"job01\", \"number\": 1, \"action\": \"status\"})\n", + "if not resp[\"inProgress\"]:\n", + " print(resp[\"result\"])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "4. Delete the jenkins job" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "tools[0].invoke({\"job\": \"job01\", \"action\": \"delete\"})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Chaining\n", + "\n", + "TODO.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## API reference\n", + "\n", + "For detailed documentation [API reference](https://python.langchain.com/docs/integrations/tools/jenkins/)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.1" + }, + "vscode": { + "interpreter": { + "hash": "3929050b09828356c9f5ebaf862d05c053d8228eddbc70f990c168e54dd824ba" + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/libs/packages.yml b/libs/packages.yml index 1582c8a196f..0665b3b10f0 100644 --- a/libs/packages.yml +++ b/libs/packages.yml @@ -371,3 +371,7 @@ packages: downloads: 0 js: '@langchain/deepseek' provider_page: deepseek +- name: langchain-jenkins + path: . + repo: Amitgb14/langchain_jenkins + downloads: 0