jenkinsctl 0.0.7__tar.gz → 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of jenkinsctl might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jenkinsctl
3
- Version: 0.0.7
3
+ Version: 0.1.0
4
4
  Summary: Build Jenkins jobs effortlessly using a single command. 🚀
5
5
  Author-email: Aman Shaw <amanshaw4511@protonmail.com>
6
6
  Project-URL: Homepage, https://github.com/amanshaw4511/jenkinsctl
@@ -18,7 +18,7 @@ Requires-Dist: dynaconf
18
18
  Requires-Dist: pyyaml
19
19
  Requires-Dist: argcomplete
20
20
 
21
- # jenkinsctl
21
+ # jenkinsctl [![PyPI version](https://badge.fury.io/py/jenkinsctl.svg)](https://badge.fury.io/py/jenkinsctl) [![Downloads](https://static.pepy.tech/badge/jenkinsctl/week)](https://pepy.tech/project/jenkinsctl)
22
22
  Build Jenkins jobs effortlessly using a single command. 🚀
23
23
 
24
24
  ## Installation 📦
@@ -37,6 +37,7 @@ export JENKINS_API_KEY=21df49caf41726094323b803a6de363eae
37
37
  ```
38
38
  Adjust the values to match your Jenkins server's URL, your username, and the corresponding API key. This configuration is essential for jenkinsctl to interact with Jenkins and execute tasks efficiently.
39
39
 
40
+ How to Get the API Token: https://www.baeldung.com/ops/jenkins-api-token
40
41
  ## Usage 🤖
41
42
  ```sh
42
43
  $ jenkinsctl --help
@@ -95,7 +96,7 @@ This command executes the job based on the specified YAML configuration.
95
96
 
96
97
  ### Overriding Specific Parameter from Configuration
97
98
  ```sh
98
- jenkinsctl build -f my_job.yaml --param param2=11 --param3=false
99
+ jenkinsctl build -f my_job.yaml --param param2=11 --param param3=false
99
100
  ```
100
101
  This command will override the value of `param2` and `param3` from original configuration file `my_job.yaml`, passing an effective configuration as follows to run jenkin job :
101
102
  ```yaml
@@ -105,6 +106,9 @@ params:
105
106
  param2: 11
106
107
  param3: false
107
108
  ```
109
+ .. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/shtab.svg?label=pypi%20downloads&logo=PyPI&logoColor=white
110
+ :target: https://pepy.tech/project/shtab
111
+ :alt: Downloads
108
112
 
109
113
  ### Generating Config from Existing Builds
110
114
  Capture and reproduce configurations from previous Jenkins builds.
@@ -1,4 +1,4 @@
1
- # jenkinsctl
1
+ # jenkinsctl [![PyPI version](https://badge.fury.io/py/jenkinsctl.svg)](https://badge.fury.io/py/jenkinsctl) [![Downloads](https://static.pepy.tech/badge/jenkinsctl/week)](https://pepy.tech/project/jenkinsctl)
2
2
  Build Jenkins jobs effortlessly using a single command. 🚀
3
3
 
4
4
  ## Installation 📦
@@ -17,6 +17,7 @@ export JENKINS_API_KEY=21df49caf41726094323b803a6de363eae
17
17
  ```
18
18
  Adjust the values to match your Jenkins server's URL, your username, and the corresponding API key. This configuration is essential for jenkinsctl to interact with Jenkins and execute tasks efficiently.
19
19
 
20
+ How to Get the API Token: https://www.baeldung.com/ops/jenkins-api-token
20
21
  ## Usage 🤖
21
22
  ```sh
22
23
  $ jenkinsctl --help
@@ -75,7 +76,7 @@ This command executes the job based on the specified YAML configuration.
75
76
 
76
77
  ### Overriding Specific Parameter from Configuration
77
78
  ```sh
78
- jenkinsctl build -f my_job.yaml --param param2=11 --param3=false
79
+ jenkinsctl build -f my_job.yaml --param param2=11 --param param3=false
79
80
  ```
80
81
  This command will override the value of `param2` and `param3` from original configuration file `my_job.yaml`, passing an effective configuration as follows to run jenkin job :
81
82
  ```yaml
@@ -85,10 +86,13 @@ params:
85
86
  param2: 11
86
87
  param3: false
87
88
  ```
89
+ .. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/shtab.svg?label=pypi%20downloads&logo=PyPI&logoColor=white
90
+ :target: https://pepy.tech/project/shtab
91
+ :alt: Downloads
88
92
 
89
93
  ### Generating Config from Existing Builds
90
94
  Capture and reproduce configurations from previous Jenkins builds.
91
95
  To generate a YAML configuration file from a specific build (e.g. 2nd build) of a job (e.g., `my_job`), use the following command:
92
96
  ```sh
93
97
  jenkinsctl config my_job 2 > my_job.yaml
94
- ```
98
+ ```
@@ -0,0 +1,8 @@
1
+
2
+
3
+ def use_vprint(verbose_flag):
4
+ def vprint(*args, **kwargs):
5
+ if verbose_flag:
6
+ print(*args, **kwargs)
7
+
8
+ return vprint
@@ -6,6 +6,8 @@ import sys
6
6
  import yaml
7
7
  from threading import Thread
8
8
 
9
+ from .commons import use_vprint
10
+
9
11
 
10
12
  def handle_build_command(args):
11
13
  vprint = use_vprint(args.verbose)
@@ -17,14 +19,6 @@ def handle_build_command(args):
17
19
  create_build(args.client, conf, args.suppress_logs, vprint)
18
20
 
19
21
 
20
- def use_vprint(verbose_flag):
21
- def vprint(*args, **kwargs):
22
- if verbose_flag:
23
- print(*args, **kwargs)
24
-
25
- return vprint
26
-
27
-
28
22
  def get_config_from_yaml(file):
29
23
  config_data = None
30
24
  try:
@@ -111,9 +105,11 @@ def create_build(client, conf, suppress_logs: bool, vprint=print):
111
105
 
112
106
  approve_pending_input_thread.join()
113
107
 
108
+ if build.result == "FAILURE":
109
+ print(f"FAILED... build number : {build_number}")
110
+ sys.exit(1)
111
+
114
112
  if not suppress_logs:
115
113
  print(f"FINISHED... build number : {build_number}")
116
114
  else:
117
115
  print(build_number)
118
-
119
- return build_number
@@ -45,7 +45,8 @@ def add_get_config_subparser(subparsers):
45
45
  subparser = subparsers.add_parser("config", help="get config of a build")
46
46
  subparser.set_defaults(func=handle_get_config, client=get_client)
47
47
  subparser.add_argument("job_name")
48
- subparser.add_argument("build_no", type=int)
48
+ subparser.add_argument("build_no", type=int, nargs="?")
49
+ subparser.add_argument("-v", "--verbose", action="store_true")
49
50
 
50
51
 
51
52
  if __name__ == '__main__':
@@ -0,0 +1,41 @@
1
+ import yaml
2
+
3
+ from .commons import use_vprint
4
+
5
+
6
+ def handle_get_config(args):
7
+ vprint = use_vprint(args.verbose)
8
+ vprint(f"Passed args : {vars(args)}")
9
+
10
+ client = args.client()
11
+
12
+ job_name = args.job_name
13
+
14
+ build = get_build(client, vprint, job_name, args.build_no)
15
+
16
+ params = get_params(build)
17
+
18
+ print(to_yaml(job_name, params))
19
+
20
+
21
+ def get_build(client, vprint, job_name, build_no):
22
+ job = client.get_job(job_name)
23
+
24
+ final_build_no = get_last_build_no(job) if build_no is None else build_no
25
+ vprint(f"final build no {final_build_no}")
26
+
27
+ build = job.get(final_build_no)
28
+
29
+ return build
30
+
31
+
32
+ def get_last_build_no(job):
33
+ return job.get_last_build().number
34
+
35
+
36
+ def get_params(build):
37
+ return dict([(param.name, param.value) for param in build.get_parameters()])
38
+
39
+
40
+ def to_yaml(job_name, params):
41
+ return yaml.dump({"job": job_name, "params": params})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jenkinsctl
3
- Version: 0.0.7
3
+ Version: 0.1.0
4
4
  Summary: Build Jenkins jobs effortlessly using a single command. 🚀
5
5
  Author-email: Aman Shaw <amanshaw4511@protonmail.com>
6
6
  Project-URL: Homepage, https://github.com/amanshaw4511/jenkinsctl
@@ -18,7 +18,7 @@ Requires-Dist: dynaconf
18
18
  Requires-Dist: pyyaml
19
19
  Requires-Dist: argcomplete
20
20
 
21
- # jenkinsctl
21
+ # jenkinsctl [![PyPI version](https://badge.fury.io/py/jenkinsctl.svg)](https://badge.fury.io/py/jenkinsctl) [![Downloads](https://static.pepy.tech/badge/jenkinsctl/week)](https://pepy.tech/project/jenkinsctl)
22
22
  Build Jenkins jobs effortlessly using a single command. 🚀
23
23
 
24
24
  ## Installation 📦
@@ -37,6 +37,7 @@ export JENKINS_API_KEY=21df49caf41726094323b803a6de363eae
37
37
  ```
38
38
  Adjust the values to match your Jenkins server's URL, your username, and the corresponding API key. This configuration is essential for jenkinsctl to interact with Jenkins and execute tasks efficiently.
39
39
 
40
+ How to Get the API Token: https://www.baeldung.com/ops/jenkins-api-token
40
41
  ## Usage 🤖
41
42
  ```sh
42
43
  $ jenkinsctl --help
@@ -95,7 +96,7 @@ This command executes the job based on the specified YAML configuration.
95
96
 
96
97
  ### Overriding Specific Parameter from Configuration
97
98
  ```sh
98
- jenkinsctl build -f my_job.yaml --param param2=11 --param3=false
99
+ jenkinsctl build -f my_job.yaml --param param2=11 --param param3=false
99
100
  ```
100
101
  This command will override the value of `param2` and `param3` from original configuration file `my_job.yaml`, passing an effective configuration as follows to run jenkin job :
101
102
  ```yaml
@@ -105,6 +106,9 @@ params:
105
106
  param2: 11
106
107
  param3: false
107
108
  ```
109
+ .. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/shtab.svg?label=pypi%20downloads&logo=PyPI&logoColor=white
110
+ :target: https://pepy.tech/project/shtab
111
+ :alt: Downloads
108
112
 
109
113
  ### Generating Config from Existing Builds
110
114
  Capture and reproduce configurations from previous Jenkins builds.
@@ -2,6 +2,7 @@ LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
4
  jenkinsctl/__init__.py
5
+ jenkinsctl/commons.py
5
6
  jenkinsctl/config.py
6
7
  jenkinsctl/jbuild.py
7
8
  jenkinsctl/jenkins.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jenkinsctl"
7
- version = "v0.0.7"
7
+ version = "v0.1.0"
8
8
  dependencies = ["api4jenkins", "dynaconf", "pyyaml", "argcomplete"]
9
9
  authors = [{ name = "Aman Shaw", email = "amanshaw4511@protonmail.com" }]
10
10
  description = "Build Jenkins jobs effortlessly using a single command. 🚀"
@@ -1,19 +0,0 @@
1
- import yaml
2
-
3
- def handle_get_config(args):
4
- # print(args)
5
- client = args.client()
6
- job_name = args.job_name
7
-
8
- job = client.get_job(job_name)
9
- build = job.get(int(args.build_no))
10
- params = get_params(build)
11
- print(to_yaml(job_name, params))
12
-
13
-
14
- def get_params(build):
15
- return dict([ (param.name, param.value) for param in build.get_parameters() ])
16
-
17
- def to_yaml(job_name, params):
18
- return yaml.dump( { "job" : job_name, "params": params})
19
-
File without changes
File without changes