|
| 1 | +# jenkins-share-library |
| 2 | + |
| 3 | +This repo contains share library used by DevStream plugin "jenkins-pipeline" (thereafter: the plugin). It currently has the following functions: |
| 4 | +- send notification to dingtalk when pipeline result is success or failed. |
| 5 | +- run test for java project. |
| 6 | +- run sonar scanner for java project. |
| 7 | +- build docker image by current project, and push this image to image repo. |
| 8 | + |
| 9 | +## example |
| 10 | +```groovy dingtalk |
| 11 | +/* |
| 12 | +config dingtalk related info, if not set, pipeline result will not be sent |
| 13 | +required plugins: dingding-notifications |
| 14 | +*/ |
| 15 | +setting.configNotifyDingtalk([ |
| 16 | + 'robot_id': "dingdingtest", // robotID in jenkins config |
| 17 | + 'at_user': "" |
| 18 | +]) |
| 19 | +
|
| 20 | +/* |
| 21 | +config docker image repo info, if not set, image will not be sent to repo |
| 22 | +*/ |
| 23 | +setting.configImageRepo([ |
| 24 | + 'image_repo': "test.com/library", |
| 25 | + 'image_auth_secret_name': "docker-config", |
| 26 | +]) |
| 27 | +
|
| 28 | +/* |
| 29 | +pipeline generic config |
| 30 | +*/ |
| 31 | +runPipeline([ |
| 32 | + 'enable_test': true, // whether run test for code |
| 33 | + 'name': "spring-test-github", // this name will be used for image repo name and sonar project name |
| 34 | + 'enable_sonarqube': true, // whether use sonar to scan code |
| 35 | +]) |
| 36 | +
|
| 37 | +``` |
| 38 | + |
| 39 | +## general config variables |
| 40 | + |
| 41 | +| field | description | default_value | |
| 42 | +| ---- | ---- | ---- | |
| 43 | +| repo_type | whether code repo is github or gitlab, if repo_type is gitlab, we can use gitlab_connection to show jenkins pipeline status in gitlab | | |
| 44 | +| name | this name will be used for image repo name and sonar project name | | |
| 45 | +| language | the project language, current only support Java | java | |
| 46 | +| container_requests_cpu | jenkins worker container requests cpu | 0.3 | |
| 47 | +| container_requests_memory | jenkins worker container requests memory | 512Mi | |
| 48 | +| container_limit_cpu | jenkins worker container limit cpu | 1 | |
| 49 | +| container_limit_memory | jenkins worker container limit memory | 2Gi | |
| 50 | +| enable_test | whether run test for code | true | |
| 51 | +| enable_sonarqube | whether use sonar to scan code | false | |
| 52 | + |
| 53 | +_this repo is synced from [devstream](https://github.com/devstream-io/devstream/tree/main/staging/pipeline-templates), please request pr through the devstream repo._ |
0 commit comments