{"id":21301732,"url":"https://github.com/funbox/pipeline-heavy-job-plugin","last_synced_at":"2025-07-11T20:31:23.080Z","repository":{"id":42175319,"uuid":"282163228","full_name":"funbox/pipeline-heavy-job-plugin","owner":"funbox","description":"This plugin allows defining job weight for pipeline projects as HeavyJob Plugin does for freestyle projects.","archived":false,"fork":false,"pushed_at":"2022-04-11T19:02:58.000Z","size":40,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T08:35:30.286Z","etag":null,"topics":["heavyjob","jenkins","pipeline"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":false,"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/funbox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-24T08:17:33.000Z","updated_at":"2024-05-02T14:38:15.000Z","dependencies_parsed_at":"2022-08-12T08:41:01.122Z","dependency_job_id":null,"html_url":"https://github.com/funbox/pipeline-heavy-job-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/funbox/pipeline-heavy-job-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fpipeline-heavy-job-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fpipeline-heavy-job-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fpipeline-heavy-job-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fpipeline-heavy-job-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funbox","download_url":"https://codeload.github.com/funbox/pipeline-heavy-job-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fpipeline-heavy-job-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264892200,"owners_count":23679252,"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":["heavyjob","jenkins","pipeline"],"created_at":"2024-11-21T15:50:37.780Z","updated_at":"2025-07-11T20:31:18.069Z","avatar_url":"https://github.com/funbox.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pipeline HeavyJob Plugin\n\nThis plugin allows defining job weights for pipeline projects like\n[HeavyJob Plugin](https://github.com/jenkinsci/heavy-job-plugin) does for\nfreestyle projects.\n\n[По-русски](./README.ru.md)\n\n## Usage\n\nPipeline:\n\n```groovy\nnodeWithWeight(label: 'nodejs', weight: 2) {\n    echo 'Run heavy tests'\n}\n```\n\nPipeline Declarative Syntax:\n\n```groovy\npipeline {\n    agent {\n        nodeWithWeight {\n            label 'nodejs'\n            weight 2\n        }\n    }\n    stages {\n        stage('Build') {\n            steps {\n                echo 'Run heavy build'\n            }\n        }\n    }\n}\n```\n\n## Rationale\n\nA typical big Jenkins setup consists of the main server with several worker nodes.\nEach node has several slots. By default one build occupies one slot. Some builds\nwill wait in a queue if there are no more free slots available.\n\nEach node has a limited amount of resources like CPU, RAM, or network bandwidth. Different\nbuilds require different amounts of these resources but each build occupies only\none slot. That is why in some cases one node can be overloaded and another one\ncan be almost idle.\n\nThere are several ways to solve this problem.\n\nSuppose we have two types of builds: light and heavy. A heavy build requires\ntwice as much resources as a light one. Suppose we have two worker nodes. Each\nnode has enough resources to run two parallel light builds or one heavy build.\n\nWe want to run as many builds as possible but do it in such a way that none of\nthe nodes will be overloaded.\n\n### Separate worker for heavy builds\n\nThe idea is to configure Jenkins setup this way:\n\n* worker 1 should have 2 slots and perform only light builds;\n* worker 2 should have 1 slot and perform light and heavy builds.\n\nPros: workers will never be overloaded.\nCons: in some cases worker 2 will utilize only half of the available resources.\n\n### lockable-resources\n\nConfigure 4 resources named “slot” using\n[lockable-resources](https://www.jenkins.io/doc/pipeline/steps/lockable-resources/).\nFor a light build lock one “slot” resource:\n\n```groovy\nlock(label: 'slot', quantity: 1) {\n    echo 'Perform light build'\n}\n```\nFor a heavy build — lock 2 resources:\n\n```groovy\nlock(label: 'slot', quantity: 2) {\n    echo 'Perform heavy build'\n}\n```\n\nPros: workers will run as many builds as possible.\nCons: in some cases workers can be overloaded.\n\n### Freestyle projects\n\nIt's possible to use freestyle projects with\n[HeavyJob Plugin](https://github.com/jenkinsci/heavy-job-plugin) which solves\nthe problem completely.\n\nPros: workers will run as many builds as possible, workers won't be overloaded.\nCons: we can't use configuration as a code.\n\n### Conclusion\n\nEach described solution has pros and cons and it will be very useful to have\nsomething like HeavyJob Plugin but for pipeline projects. As I've found in\n[Jenkins Jira](https://issues.jenkins-ci.org/browse/JENKINS-41940) there are no\nsuch plugins. That is why Pipeline HeavyJob Plugin was developed.\n\n## Implementation details\n\nThis plugin implements `nodeWithWeight` step and `nodeWithWeight` agent based on\nit. The code of the plugin is based on the code of\n[workflow-durable-task-step-plugin](https://github.com/jenkinsci/workflow-durable-task-step-plugin).\n\n[![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fpipeline-heavy-job-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunbox%2Fpipeline-heavy-job-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fpipeline-heavy-job-plugin/lists"}