Skip to content

Commit 0c40524

Browse files
Amitgb14ccurme
andauthored
[Integrations][Tool] Added Jenkins tools support (#29516)
Thank you for contributing to LangChain! - [x] **PR title**: "package: description" - Where "package" is whichever of langchain, community, core, etc. is being modified. Use "docs: ..." for purely docs changes, "infra: ..." for CI changes. - Example: "community: add foobar LLM" - [x] **PR message**: ***Delete this entire checklist*** and replace with - **Description:** a description of the change - **Issue:** the issue # it fixes, if applicable - **Dependencies:** any dependencies required for this change - **Twitter handle:** if your PR gets announced, and you'd like a mention, we'll gladly shout you out! - [x] **Add tests and docs**: If you're adding a new integration, please include 1. a test for the integration, preferably unit tests that do not rely on network access, 2. an example notebook showing its use. It lives in `docs/docs/integrations` directory. - [x] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/ Additional guidelines: - Make sure optional dependencies are imported within a function. - Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. - Most PRs should not touch more than one package. - Changes should be backwards compatible. - If you are adding something to community, do not re-import it in langchain. If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17. --------- Co-authored-by: Chester Curme <[email protected]>
1 parent 5b82617 commit 0c40524

File tree

3 files changed

+246
-0
lines changed

3 files changed

+246
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Jenkins
2+
3+
[Jenkins](https://www.jenkins.io/) is an open-source automation platform that enables
4+
software teams to streamline their development workflows. It's widely adopted in the
5+
DevOps community as a tool for automating the building, testing, and deployment of
6+
applications through CI/CD pipelines.
7+
8+
9+
## Installation and Setup
10+
11+
```bash
12+
pip install langchain-jenkins
13+
```
14+
15+
## Tools
16+
17+
See detail on available tools [here](/docs/integrations/tools/jenkins).
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Jenkins\n",
8+
"\n",
9+
"Tools for interacting with [Jenkins](https://www.jenkins.io/).\n"
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"## Overview\n",
17+
"\n",
18+
"The `langchain-jenkins` package allows you to execute and control CI/CD pipelines with\n",
19+
"Jenkins."
20+
]
21+
},
22+
{
23+
"cell_type": "markdown",
24+
"metadata": {},
25+
"source": [
26+
"### Setup\n",
27+
"\n",
28+
"Install `langchain-jenkins`:"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": null,
34+
"metadata": {
35+
"vscode": {
36+
"languageId": "shellscript"
37+
}
38+
},
39+
"outputs": [],
40+
"source": [
41+
"%pip install --upgrade --quiet langchain-jenkins"
42+
]
43+
},
44+
{
45+
"cell_type": "markdown",
46+
"metadata": {},
47+
"source": [
48+
"### Credentials\n",
49+
"\n",
50+
"You'll need to setup or obtain authorization to access Jenkins server."
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": null,
56+
"metadata": {
57+
"vscode": {
58+
"languageId": "shellscript"
59+
}
60+
},
61+
"outputs": [],
62+
"source": [
63+
"import getpass\n",
64+
"import os\n",
65+
"\n",
66+
"\n",
67+
"def _set_env(var: str):\n",
68+
" if not os.environ.get(var):\n",
69+
" os.environ[var] = getpass.getpass(f\"{var}: \")\n",
70+
"\n",
71+
"\n",
72+
"_set_env(\"PASSWORD\")"
73+
]
74+
},
75+
{
76+
"cell_type": "markdown",
77+
"metadata": {},
78+
"source": [
79+
"## Instantiation\n",
80+
"To disable the SSL Verify, set `os.environ[\"PYTHONHTTPSVERIFY\"] = \"0\"`"
81+
]
82+
},
83+
{
84+
"cell_type": "code",
85+
"execution_count": null,
86+
"metadata": {},
87+
"outputs": [],
88+
"source": [
89+
"from langchain_jenkins import JenkinsAPIWrapper, JenkinsJobRun\n",
90+
"\n",
91+
"tools = [\n",
92+
" JenkinsJobRun(\n",
93+
" api_wrapper=JenkinsAPIWrapper(\n",
94+
" jenkins_server=\"https://example.com\",\n",
95+
" username=\"admin\",\n",
96+
" password=os.environ[\"PASSWORD\"],\n",
97+
" )\n",
98+
" )\n",
99+
"]"
100+
]
101+
},
102+
{
103+
"cell_type": "markdown",
104+
"metadata": {},
105+
"source": [
106+
"## Invocation\n",
107+
"You can now call invoke and pass arguments."
108+
]
109+
},
110+
{
111+
"cell_type": "markdown",
112+
"metadata": {},
113+
"source": [
114+
"1. Create the Jenkins job"
115+
]
116+
},
117+
{
118+
"cell_type": "code",
119+
"execution_count": null,
120+
"metadata": {},
121+
"outputs": [],
122+
"source": [
123+
"jenkins_job_content = \"\"\n",
124+
"src_file = \"job1.xml\"\n",
125+
"with open(src_file) as fread:\n",
126+
" jenkins_job_content = fread.read()\n",
127+
"tools[0].invoke({\"job\": \"job01\", \"config_xml\": jenkins_job_content, \"action\": \"create\"})"
128+
]
129+
},
130+
{
131+
"cell_type": "markdown",
132+
"metadata": {},
133+
"source": [
134+
"2. Run the Jenkins Job"
135+
]
136+
},
137+
{
138+
"cell_type": "code",
139+
"execution_count": null,
140+
"metadata": {},
141+
"outputs": [],
142+
"source": [
143+
"tools[0].invoke({\"job\": \"job01\", \"parameters\": {}, \"action\": \"run\"})"
144+
]
145+
},
146+
{
147+
"cell_type": "markdown",
148+
"metadata": {},
149+
"source": [
150+
"3. Get job info"
151+
]
152+
},
153+
{
154+
"cell_type": "code",
155+
"execution_count": null,
156+
"metadata": {},
157+
"outputs": [],
158+
"source": [
159+
"resp = tools[0].invoke({\"job\": \"job01\", \"number\": 1, \"action\": \"status\"})\n",
160+
"if not resp[\"inProgress\"]:\n",
161+
" print(resp[\"result\"])"
162+
]
163+
},
164+
{
165+
"cell_type": "markdown",
166+
"metadata": {},
167+
"source": [
168+
"4. Delete the jenkins job"
169+
]
170+
},
171+
{
172+
"cell_type": "code",
173+
"execution_count": null,
174+
"metadata": {},
175+
"outputs": [],
176+
"source": [
177+
"tools[0].invoke({\"job\": \"job01\", \"action\": \"delete\"})"
178+
]
179+
},
180+
{
181+
"cell_type": "markdown",
182+
"metadata": {},
183+
"source": [
184+
"## Chaining\n",
185+
"\n",
186+
"TODO.\n"
187+
]
188+
},
189+
{
190+
"cell_type": "markdown",
191+
"metadata": {},
192+
"source": [
193+
"## API reference\n",
194+
"\n",
195+
"For detailed documentation [API reference](https://python.langchain.com/docs/integrations/tools/jenkins/)"
196+
]
197+
}
198+
],
199+
"metadata": {
200+
"kernelspec": {
201+
"display_name": "Python 3 (ipykernel)",
202+
"language": "python",
203+
"name": "python3"
204+
},
205+
"language_info": {
206+
"codemirror_mode": {
207+
"name": "ipython",
208+
"version": 3
209+
},
210+
"file_extension": ".py",
211+
"mimetype": "text/x-python",
212+
"name": "python",
213+
"nbconvert_exporter": "python",
214+
"pygments_lexer": "ipython3",
215+
"version": "3.9.1"
216+
},
217+
"vscode": {
218+
"interpreter": {
219+
"hash": "3929050b09828356c9f5ebaf862d05c053d8228eddbc70f990c168e54dd824ba"
220+
}
221+
}
222+
},
223+
"nbformat": 4,
224+
"nbformat_minor": 4
225+
}

libs/packages.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,7 @@ packages:
371371
downloads: 0
372372
js: '@langchain/deepseek'
373373
provider_page: deepseek
374+
- name: langchain-jenkins
375+
path: .
376+
repo: Amitgb14/langchain_jenkins
377+
downloads: 0

0 commit comments

Comments
 (0)