{"id":16220234,"url":"https://github.com/jkandasa/jenkinsctl","last_synced_at":"2025-03-19T11:30:54.692Z","repository":{"id":144347428,"uuid":"378103414","full_name":"jkandasa/jenkinsctl","owner":"jkandasa","description":"Jenkins CLI tool","archived":false,"fork":false,"pushed_at":"2022-03-09T02:54:19.000Z","size":102,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T18:23:12.146Z","etag":null,"topics":["cli","command-line","jenkins","jenkins-cli","jenkins-client","jenkinsctl"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jkandasa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-18T09:42:44.000Z","updated_at":"2024-06-07T15:36:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"e3d32461-95ba-44be-9cc7-ff39ad65a3b6","html_url":"https://github.com/jkandasa/jenkinsctl","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkandasa%2Fjenkinsctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkandasa%2Fjenkinsctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkandasa%2Fjenkinsctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkandasa%2Fjenkinsctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jkandasa","download_url":"https://codeload.github.com/jkandasa/jenkinsctl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243985913,"owners_count":20379228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","jenkins","jenkins-cli","jenkins-client","jenkinsctl"],"created_at":"2024-10-10T11:58:13.726Z","updated_at":"2025-03-19T11:30:54.685Z","avatar_url":"https://github.com/jkandasa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jenkinsctl\n`jenkinsctl` is a command line tool to interact with jenkins server.\u003cbr\u003e\nInspired by `kubectl` and `oc` (OpenShift) client.\n\n### Download the client\n* [Releases](https://github.com/jkandasa/jenkinsctl/releases/latest)\n* [Pre Release](https://github.com/jkandasa/jenkinsctl/releases/tag/master) - `master` branch build\n\n### Commands\n```\n$ jenkinsctl --help \nJenkins Client\n  \nThis client helps you to control your jenkins server from command line.\n\nUsage:\n  jenkinsctl [command]\n\nAvailable Commands:\n  completion  Generate the autocompletion script for the specified shell\n  create      Create a resource from a file or stdin\n  download    Download resources from Jenkins server\n  get         Display one or many resources\n  help        Help about any command\n  job         Switch or set a job\n  jobs        Display existing jobs\n  login       Log in to a server\n  logout      Log out from a server\n  status      Displays an overview of the jenkins server\n  version     Print the client and server version information\n\nFlags:\n      --config string   config file (default is $HOME/.jenkinsctl.yaml)\n  -h, --help            help for jenkinsctl\n      --hide-header     hides the header on the console output\n  -j, --job string      Switch to another job\n  -o, --output string   output format. options: yaml, json, console (default \"console\")\n      --pretty          JSON pretty print\n\nUse \"jenkinsctl [command] --help\" for more information about a command.\n```\n### Examples\nTo get login token,\n\u003e The API token is available in your personal configuration page. Click your name on the top right corner on every page, then click \"Configure\" to see your API token. (The URL `$root/me/configure` is a good shortcut.) You can also change your API token from here.\n\nSource: [Jenkins doc](https://www.jenkins.io/doc/book/system-administration/authenticating-scripted-clients/)\n\n#### Login to jenkins server\n```bash\n$ jenkinsctl login http://localhost:8080 --username jeeva --password 11f3d04172eb97b3f4c0287911e5832b00\nLogin successful.\n\n# prints the version details\n$ jenkinsctl version\nClient Version: {version:master, buildDate:2021-06-21T17:09:18+00:00, gitCommit:5878ed77e8c28eeae04cb2311bbe44deabaff6b2, goLangVersion:go1.16.3, platform:linux/amd64}\nServer Version: 2.289.1\n\n```\n#### Display jobs\n```bash\n$ jenkinsctl jobs\nCOLOR   \tNAME                      \tCLASS                                         \tURL                                                   \n        \tJobFolder1/job/Foleder2   \tcom.cloudbees.hudson.plugins.folder.Folder    \thttp://localhost:8080/job/JobFolder1/job/Foleder2/   \t\nnotbuilt\tJobFolder1/job/folder-job1\thudson.model.FreeStyleProject                 \thttp://localhost:8080/job/JobFolder1/job/folder-job1/\t\nred     \tpipeline job              \torg.jenkinsci.plugins.workflow.job.WorkflowJob\thttp://localhost:8080/job/pipeline%20job/            \t\nblue    \ttest-job-1                \thudson.model.FreeStyleProject                 \thttp://localhost:8080/job/test-job-1/                \t\nnotbuilt\ttest-job-2                \thudson.model.FreeStyleProject                 \thttp://localhost:8080/job/test-job-2/              \t\n\n$ jenkinsctl jobs --depth 2\nCOLOR   \tNAME                                     \tCLASS                                         \tURL                                                                    \nblue    \tJobFolder1/job/Foleder2/job/hello-job 123\thudson.model.FreeStyleProject                 \thttp://localhost:8080/job/JobFolder1/job/Foleder2/job/hello-job%20123/\t\nnotbuilt\tJobFolder1/job/folder-job1               \thudson.model.FreeStyleProject                 \thttp://localhost:8080/job/JobFolder1/job/folder-job1/                 \t\nred     \tpipeline job                             \torg.jenkinsci.plugins.workflow.job.WorkflowJob\thttp://localhost:8080/job/pipeline%20job/                             \t\nblue    \ttest-job-1                               \thudson.model.FreeStyleProject                 \thttp://localhost:8080/job/test-job-1/                                 \t\nnotbuilt\ttest-job-2                               \thudson.model.FreeStyleProject                 \thttp://localhost:8080/job/test-job-2/  \n```\n\n#### Switch to a job\n```bash\n$ jenkinsctl job test-job-1\nSwitched to 'test-job-1' at 'http://localhost:8080'\n```\n#### Display parameters of the job\n```bash\n$ jenkinsctl get parameters\nNAME  \tDEFAULT VALUE\tTYPE                      \tDESCRIPTION   \nPARAM1\ttest         \tStringParameterDefinition \tParam value 1\t\nPARAM2\ttest2        \tStringParameterDefinition \tParam value 2\t\nPARAM3\ttrue         \tBooleanParameterDefinition\tParam value 3\t\n```\n#### Build a job\n```bash\n# sample build config file\n$ cat example_build.yaml\nkind: build\nspec:\n  job_name: test-job-1\n  parameters:\n    PARAM1: custom value 1\n    PARAM2: custom value 2\n    PARAM3: false\n\n# trigger a build\n$ jenkinsctl create --file ./example_build.yaml \nbuild created on the job 'test-job-1', build queue id:123\n```\n#### Display past builds\n```bash\n$ jenkinsctl get builds --limit 2\nNUMBER\tTRIGGERED BY          \tRESULT \tIS RUNNING\tDURATION\tTIMESTAMP                        \tREVISION \n11    \tJeeva Kandasamy(jeeva)\tSUCCESS\tfalse     \t8ms     \t2021-06-21 22:26:09.756 +0530 IST\t        \t\n10    \tJeeva Kandasamy(jeeva)\tSUCCESS\tfalse     \t19ms    \t2021-06-21 22:25:55.894 +0530 IST\t        \t\n```\n#### display details of a build\n```\n$ jenkinsctl get build 11\nKEY            \tVALUE                                    \nURL            \thttp://localhost:8080/job/test-job-1/11/\t\nBuild Number   \t11                                      \t\nTriggered By   \tJeeva Kandasamy(jeeva)                  \t\nResult         \tSUCCESS                                 \t\nIs Running     \tfalse                                   \t\nDuration       \t0s                                      \t\nRevision       \t                                        \t\nRevision Branch\t                                        \t\nTimestamp      \t2021-06-21 22:26:09.756 +0530 IST       \t\n\nParameters:\nPARAM1\tcustom value 1\t\nPARAM2\tcustom value 2\t\nPARAM3\t              \t\n\nTest Result:\nKEY     \tVALUE \nPassed  \t0    \t\nFailed  \t0    \t\nSkipped \t0    \t\nDuration\t0s   \t\n\nArtifacts:\nPATH \n```\n#### Display a build details in yaml format\n```bash\n$ jenkinsctl get build 11 --output yaml\nurl: http://localhost:8080/job/test-job-1/11/\nnumber: 11\ntriggered_by: Jeeva Kandasamy(jeeva)\nparameters:\n- name: PARAM1\n  value: custom value 1\n- name: PARAM2\n  value: custom value 2\n- name: PARAM3\n  value: \"\"\ninjected_env_vars: {}\ncauses:\n- _class: hudson.model.Cause$UserIdCause\n  shortDescription: Started by user Jeeva Kandasamy\n  userId: jeeva\n  userName: Jeeva Kandasamy\nduration: 8ms\nconsole: null\nresult: SUCCESS\nis_running: false\nrevision: \"\"\nrevision_branch: \"\"\ntimestamp: 2021-06-21T22:26:09.756+05:30\ntest_result:\n  duration: 0\n  empty: false\n  failcount: 0\n  passcount: 0\n  skipcount: 0\n  suites: []\nartifacts: []\n```\n#### Display a build details in json format\n```bash\n$ jenkinsctl get build 11 --output json --pretty\n{\n \"url\": \"http://localhost:8080/job/test-job-1/11/\",\n \"number\": 11,\n \"triggeredBy\": \"Jeeva Kandasamy(jeeva)\",\n \"parameters\": [\n  {\n   \"name\": \"PARAM1\",\n   \"value\": \"custom value 1\"\n  },\n  {\n   \"name\": \"PARAM2\",\n   \"value\": \"custom value 2\"\n  },\n  {\n   \"name\": \"PARAM3\",\n   \"value\": \"\"\n  }\n ],\n \"injectedEnvVars\": null,\n \"causes\": [\n  {\n   \"_class\": \"hudson.model.Cause$UserIdCause\",\n   \"shortDescription\": \"Started by user Jeeva Kandasamy\",\n   \"userId\": \"jeeva\",\n   \"userName\": \"Jeeva Kandasamy\"\n  }\n ],\n \"duration\": 8000000,\n \"console\": null,\n \"result\": \"SUCCESS\",\n \"isRunning\": false,\n \"revision\": \"\",\n \"revisionBranch\": \"\",\n \"timestamp\": \"2021-06-21T22:26:09.756+05:30\",\n \"testResult\": {\n  \"duration\": 0,\n  \"empty\": false,\n  \"failCount\": 0,\n  \"passCount\": 0,\n  \"skipCount\": 0,\n  \"suites\": null\n },\n \"artifacts\": null\n```\n#### Display the console log of a build\n```bash\n$ jenkinsctl get console 11\nStarted by user Jeeva Kandasamy\nRunning as SYSTEM\nBuilding in workspace /var/jenkins_home/workspace/test-job-1\n[test-job-1] $ /bin/sh -xe /tmp/jenkins2269490024621194842.sh\n...\nWORKSPACE_TMP=/var/jenkins_home/workspace/test-job-1@tmp\n+ date\nMon 21 Jun 2021 04:56:09 PM UTC\n+ hostname\n33501f943b12\nFinished: SUCCESS\n\n# watch running builds console logs\n$ jenkinsctl get console 12 --watch\nStarted by user Jeeva Kandasamy\nRunning as SYSTEM\nBuilding in workspace /var/jenkins_home/workspace/test-job-1\n[test-job-1] $ /bin/sh -xe /tmp/jenkins2269490024621194842.sh\n...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkandasa%2Fjenkinsctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjkandasa%2Fjenkinsctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkandasa%2Fjenkinsctl/lists"}