{"id":15373731,"url":"https://github.com/debugtalk/jenkins-remote-trigger","last_synced_at":"2025-03-20T11:48:13.527Z","repository":{"id":87470102,"uuid":"100441200","full_name":"debugtalk/jenkins-remote-trigger","owner":"debugtalk","description":"Trigger remote Jenkins job in Jenkins command shell.","archived":false,"fork":false,"pushed_at":"2017-08-17T08:19:10.000Z","size":70,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-25T12:11:32.303Z","etag":null,"topics":["jenkins-jobs","jenkins-trigger"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/debugtalk.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":"2017-08-16T02:55:42.000Z","updated_at":"2022-03-06T03:12:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4415025-496d-4f8e-91c9-3945227645e7","html_url":"https://github.com/debugtalk/jenkins-remote-trigger","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"d4feb467cb3c36b8c038a4e03c9983e92ccfb133"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debugtalk%2Fjenkins-remote-trigger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debugtalk%2Fjenkins-remote-trigger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debugtalk%2Fjenkins-remote-trigger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debugtalk%2Fjenkins-remote-trigger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/debugtalk","download_url":"https://codeload.github.com/debugtalk/jenkins-remote-trigger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244609432,"owners_count":20480781,"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":["jenkins-jobs","jenkins-trigger"],"created_at":"2024-10-01T13:56:11.556Z","updated_at":"2025-03-20T11:48:13.503Z","avatar_url":"https://github.com/debugtalk.png","language":"Python","readme":"# jenkins-remote-trigger\n\nTrigger remote Jenkins job in Jenkins command shell.\n\n## Background\n\nSuppose you have two Jenkins jobs. The first job mainly targets for building and deploying, and the second job is related to integration test, such as API test or UI test.\n\n![](flow-chart.png)\n\nIn some cases, these two jobs can not be executed on the same machine. For instance, the build is related to `Windows` platform, while the test can only run on `Linux` platform. As a consequence, we have to configure two jobs to do respective works.\n\nAlthough we can configure `Build other projects` in Jenkins job, thus the second job can be triggered after the former job finished. However in this case, even if the latter job failed, the former job will still be marked as success and its status can not be changed. That's not what we want.\n\nWe want the running status of the former Jenkins job not only depend on its own build, but also depend on the latter build result.\n\nAnd that is the origin aim of this project.\n\n## Solution\n\nThe solution is simple.\n\nIn the post part of the former job's shell execution, we can trigger another Jenkins job remotely, block until remote build finished, and get its build result to determine if we should fail the current job.\n\nTo achieve this goal, we need to access resources and handle with remote Jenkins server, and the [pycontribs/jenkinsapi][jenkinsapi] library will be of great help.\n\n## Usage\n\nIn the former Jenkins job configuration, we can add the following bash scripts to the tail of shell scripts.\n\n```bash\n# do the work of current job\n\n# then execute the following scripts\nrm -rf jenkins-remote-trigger\ngit clone https://github.com/debugtalk/jenkins-remote-trigger.git\ncd jenkins-remote-trigger\npip install -r requirements.txt\npython jenkins_remote_trigger.py \\\n    --host http://192.168.0.169:8080 \\\n    --username api-user \\\n    --password api-passwd \\\n    --job-name Prj-SmokeTest \\\n    --mail-recepients ${MAIL_RECEPIENTS}\n```\n\nIf you are using Windows platform, use the scripts below instead.\n\n```bash\n# do the work of current job\n\n# then execute the following scripts\nrmdir /Q /S jenkins-remote-trigger\ngit clone https://github.com/debugtalk/jenkins-remote-trigger.git\ncd jenkins-remote-trigger\npip.exe install -r requirements.txt\npython.exe jenkins_remote_trigger.py ^\n    --host http://192.168.0.169:8080 ^\n    --username api-user ^\n    --password api-passwd ^\n    --job-name Prj-SmokeTest ^\n    --mail-recepients %MAIL_RECEPIENTS%\n```\n\n## Limitation Notice\n\nThis solution has a limitation: the triggered job can not be on the same node with the current job.\n\nBecause the first job will block until the second job finished, while the second job can only be started to build after the former job ends if they are on the same node, which leads to a dead lock.\n\n\n\n[jenkinsapi]: https://github.com/pycontribs/jenkinsapi\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebugtalk%2Fjenkins-remote-trigger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdebugtalk%2Fjenkins-remote-trigger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebugtalk%2Fjenkins-remote-trigger/lists"}