Commit Graph

15 Commits

Author SHA1 Message Date
Bo-Yi Wu cda84c122e feat: refactor plugin config validation and enhance job error handling
- Refactor plugin configuration validation into a dedicated method with improved error messages
- Add utility functions for trimming whitespace from slices and parsing key=value parameters
- Improve error handling for missing or invalid job names and parameters
- Enhance Exec to validate configuration, clean job list, and parse parameters before triggering jobs
- Update job triggering to provide more descriptive error reporting
- Replace deprecated and less precise test assertions with more explicit ones
- Add extensive unit tests for configuration validation, whitespace trimming, parameter parsing, and job triggering (including multiple jobs, parameters, remote token, and job lists with whitespace)
- Improve test coverage and reliability for plugin behavior and edge cases

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 17:39:36 +08:00
Bo-Yi Wu 3dd86f956c feat: add remote trigger token support for Jenkins job execution
- Add support for passing a remote trigger token to Jenkins jobs
- Update the Jenkins constructor to accept a token parameter
- Ensure the token is included as a query parameter when triggering jobs
- Improve error reporting by including response body in error messages
- Remove unnecessary logging and refactor build parameter logic
- Update tests to use the new Jenkins constructor and token handling
- Add CLI option for specifying a remote trigger token
- Extend plugin configuration to support remote token injection

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 17:16:39 +08:00
appleboy 626b9e4bfa refactor: refactor codebase to use plural form 'parameters'
- Rename `parameter` to `parameters` in CLI flags and environment variables
- Update function calls to use `parameters` instead of `parameter`
- Change struct field `Parameter` to `Parameters`
- Modify loop variable to iterate over `Parameters` instead of `Parameter`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-06 08:34:10 +08:00
Bo-Yi Wu a7c6b81621 feat: support parameter handling for dynamic URL paths (#35)
- Comment out unused form data encoding in `post` method
- Remove redundant error logging in `post` method
- Add conditional URL path selection in `trigger` method based on parameters
- Add `parameter` flag to CLI options in `main.go`
- Include `parameter` in the `run` function configuration
- Import `net/url` package in `plugin.go`
- Add `Parameter` field to `plugin.go` struct
- Parse and add parameters to URL values in `Exec` method
- Pass parsed parameters to `trigger` method in `Exec` function

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-05 20:25:01 +08:00
appleboy bb1e9fe4e0 feat: improve logging and error handling in Jenkins plugin
- Add error handling for unexpected response codes in `post` method of `jenkins.go`
- Import `log` package in `plugin.go`
- Add logging for successful job trigger in `Exec` method of `plugin.go`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-05 13:28:14 +08:00
Bo-Yi Wu 1bb020b22d feat: add support for insecure TLS connections (#34)
- Add `crypto/tls` import in `jenkins.go`
- Add `Client` field to `Jenkins` struct
- Modify `NewJenkins` function to accept an `insecure` parameter and configure HTTP client accordingly
- Update `sendRequest` method to use the `Client` field from the `Jenkins` struct
- Update tests in `jenkins_test.go` to include the `insecure` parameter in `NewJenkins` calls
- Add `insecure` flag to CLI options in `main.go`
- Add `Insecure` field to `Plugin` struct
- Update `Plugin.Exec` method to pass `Insecure` field to `NewJenkins`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-05 08:41:53 +08:00
appleboy 4f822500f2 style: refactor codebase for improved consistency and clarity
- Reorder imports in `jenkins_test.go` and `plugin_test.go` to move `assert` import to the end
- Remove unnecessary empty line in `plugin.go`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:22:05 +08:00
Bo-Yi Wu beee0b43a6 chore: mirror changes 2019-03-02 10:53:03 +08:00
Bo-Yi Wu 96b11d47cd feat: check return err. 2018-11-11 11:38:23 +08:00
Bo-Yi Wu 7ba6170e12 fix: show error if missing jobs. 2017-01-16 15:04:12 +08:00
Bo-Yi Wu 1898550d88 feat: support build binary (#10) 2017-01-16 14:07:17 +08:00
Bo-Yi Wu 788418c56f refactor: remove unnecessary config. (#5) 2017-01-16 10:42:55 +08:00
Bo-Yi Wu 5257dc754c update plugin.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-10-15 21:48:09 +08:00
Bo-Yi Wu 44d62cead6 add main config.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-10-15 19:12:29 +08:00
Bo-Yi Wu 74735d5fa4 initial file
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-10-15 13:30:34 +08:00