Commit Graph

112 Commits

Author SHA1 Message Date
Bo-Yi Wu eb51e55e81 build: enable detailed build info logging in debug mode
- Add debug logging to display final build information when debug mode is enabled

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-02 19:40:30 +08:00
Bo-Yi Wu da87ddb86b docs: document and illustrate debug mode configuration options
- Document the new debug mode, including its purpose and usage
- Add examples showing how to enable debug mode via CLI, Docker, and YAML configuration
- Update the configuration table to describe the debug option and its environment variables

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-02 17:25:40 +08:00
Bo-Yi Wu 60874908e6 docs: document and standardize multi-line build parameter configurations
- Add example configurations for build parameters and waiting for job completion
- Document new settings: wait, poll_interval, timeout, insecure, and remote_token
- Update parameters format to require multi-line key=value pairs (one per line)
- Clarify handling of whitespace, empty lines, and multiple equals signs in parameter values
- Revise CLI and Docker usage examples to use multi-line parameters format
- Update YAML configuration example to use multi-line parameters block

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
v1.7.0
2025-12-02 17:09:52 +08:00
Bo-Yi Wu f6e62d9c49 feat: switch Jenkins build parameters to multi-line string format
- Change the Jenkins build parameters input from a string slice to a multi-line string format
- Update parameter parsing to handle multi-line strings, skipping empty and whitespace-only lines
- Adjust all usages and tests to support the new string-based parameter format
- Add test cases for multiple empty lines and lines containing only whitespace in parameters

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-02 16:55:46 +08:00
Bo-Yi Wu cf9b9a0a0d feat: add debug mode with enhanced logging and token masking (#41)
* feat: add debug mode with enhanced logging and token masking

- Add godump library dependency for improved debug output
- Introduce a debug mode flag to the Jenkins and Plugin structs
- Update NewJenkins constructor and all usages to support the debug flag
- Mask sensitive tokens in debug output for security
- Log detailed parameter and configuration information when debug mode is enabled
- Add CLI flag to enable debug mode via environment variables

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* fix: add error handling and logging for godump.Dump failures

- Add error handling for godump.Dump calls, logging a warning if dumping fails

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

---------

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-02 15:11:39 +08:00
Bo-Yi Wu 4c54d13899 docs: simplify Jenkins Docker setup and improve reliability
- Update Jenkins Docker run instructions to use a named volume and the slim image
- Change container restart policy to on-failure
- Remove note about creating a host directory for Jenkins data

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-02 14:36:48 +08:00
Bo-Yi Wu 627e233cc6 feat: add configurable Jenkins job wait and polling support (#40)
- Add support for waiting for Jenkins job completion with polling and timeout options
- Introduce flags and environment variables to control wait behavior, poll interval, and timeout
- Refactor the Jenkins job trigger to return queue item ID and enable job status tracking
- Implement functions for querying queue items and build status, including waiting until a build completes or times out
- Update CLI, plugin, and documentation to explain new job wait and polling capabilities
- Extend tests to cover queue item parsing, build info retrieval, and job completion scenarios with success, failure, and timeouts

Signed-off-by: appleboy <appleboy.tw@gmail.com>
v1.6.0
2025-12-01 21:53:42 +08:00
Bo-Yi Wu 747d7b23d1 docs: update Jenkins API token creation instructions and images
- Update instructions to select "Security" instead of "Configure" when creating a Jenkins API token
- Replace the token creation image with a new screenshot
- Remove the old jenkins-token.png image and add personal-token.png

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
v1.5.0
2025-12-01 17:45:49 +08:00
Bo-Yi Wu 48d5425edd ci: use Docker-based linting in CI workflow
- Update the lint workflow to use the Dockerfile located in the docker directory

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 17:41:10 +08:00
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 afbea8106e refactor: refactor Jenkins struct by removing unused methods
- Remove the parseResponse method from the Jenkins struct

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 17:29:58 +08:00
Bo-Yi Wu cc67514a1a docs: revamp README with expanded setup, usage, and integration docs
- Rewrite and expand the README with a new structure, including a Table of Contents, Features, Prerequisites, Installation, Configuration, Usage, Development, License, and Contributing sections
- Add detailed installation instructions for binary, source, and Docker image
- Provide step-by-step Jenkins server setup and authentication guidance
- Introduce a comprehensive parameters reference table for configuration
- Clarify authentication requirements and usage scenarios for CLI, Docker, and Drone CI
- Update environment variable names for consistency (use JENKINS_URL instead of JENKINS_BASE_URL)
- Add multiple usage examples for single/multiple jobs and parameterized builds
- Include instructions and examples for integrating with Drone CI pipelines
- Add development instructions for building, testing, and test coverage
- Add license and contributing information at the end of the README

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 17:28:52 +08:00
Bo-Yi Wu 3d7ffaed68 build: ensure Go build/install uses explicit current directory
- Add explicit current directory (.) to Go build and install commands to ensure correct build context

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 17:25:51 +08:00
Bo-Yi Wu 52abef124e refactor: improve CLI robustness and Jenkins integration
- Add missing .PHONY targets to the Makefile for better build reliability
- Ensure HTTP response bodies are always read and closed in Jenkins post requests
- Replace custom response parsing with direct JSON unmarshalling in Jenkins post
- Set a default value for the Version variable
- Move ASCII art to a constant and reuse for CLI help template
- Improve dotenv loading error handling and logging in main
- Update repository link in CLI help output
- Add validation for required CLI parameters and authentication in run function

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 17:23:52 +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
Bo-Yi Wu a5469c939e refactor: run container as non-root dedicated drone user
- Add a dedicated drone user and group for running the container
- Change file ownership of the drone-jenkins binary to the drone user
- Switch container execution to use the drone user instead of root

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 16:32:52 +08:00
Steve Liang a6d967789d chore(api): check Jenkins response status (#39)
When triggering a Jenkins job, Jenkins API call returns 200 OK but drone-jenkins expects 201.  So, the trigger succeeded but drone-jenkins returns false negative.
2025-12-01 16:29:54 +08:00
Bo-Yi Wu 3eb2242053 chore: migrate CLI to urfave/cli/v2 and update flag handling
- Remove formatting and vetting targets from the Makefile
- Upgrade urfave/cli dependency from v1 to v2
- Update CLI flag definitions to use urfave/cli/v2 API, including new struct field names and flag aliasing
- Add indirect dependency on github.com/xrash/smetrics

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 16:27:57 +08:00
Bo-Yi Wu 908be474f3 docs: add Trivy Security Scan badge to README
- Add a Trivy Security Scan badge to the README

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 16:24:13 +08:00
Bo-Yi Wu de494cbda1 feat: add context-aware HTTP POST and improve CLI help formatting
- Add context support to HTTP POST requests for improved cancellation and timeout handling
- Fix formatting of usage and commands help text in the CLI output

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 16:23:07 +08:00
Bo-Yi Wu 77ea4873e0 ci: modernize CI workflows and enhance security scanning
- Update GitHub Actions to use newer versions for setup-go, checkout, golangci-lint, and codecov
- Change Go version specification to use "stable" and update test matrix to only "1.25"
- Rename the test job to testing
- Adjust hadolint to use a newer version and reference the Dockerfile at the root
- Modify go test command to enable race detection and test all packages
- Add a new Trivy security scan workflow for vulnerability, secret, and misconfiguration checks, including SARIF upload and log output

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 16:21:24 +08:00
Bo-Yi Wu 36013b246a build: configure golangci-lint with custom rules and exclusions
- Add golangci-lint configuration with a custom set of enabled linters and formatters
- Exclude generated files and specific directories from linting and formatting

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 15:36:14 +08:00
Bo-Yi Wu cbfb2bb51b chore: update documentation and Docker base image version
- Fix formatting of platform list in the README
- Update Docker base image from alpine:3.20 to alpine:3.22

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 15:35:05 +08:00
Bo-Yi Wu b6589abef3 chore: update dependencies to latest stable versions
- Update testify dependency to v1.10.0
- Update urfave/cli dependency to v1.22.17
- Update go-md2man/v2 indirect dependency to v2.0.7

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-12-01 15:33:45 +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>
v1.4.1
2024-10-06 08:34:10 +08:00
appleboy e60e4b9161 chore: improve logging and testing across the codebase
- Add logging for URL path in the `trigger` function
- Remove commented-out form data encoding line
- Import the `log` package

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-06 07:59:12 +08:00
appleboy c213337305 ci: enhance CI/CD pipeline with GoReleaser integration
- Replace `go-version` with `go-version-file` and add `check-latest` in GitHub Actions workflow
- Add `.goreleaser.yaml` configuration file with build, archive, checksum, snapshot, release, and changelog settings

Signed-off-by: appleboy <appleboy.tw@gmail.com>
v1.4.0
2024-10-05 22:26:32 +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>
v1.3.4
2024-10-05 08:41:53 +08:00
appleboy 24e8004b58 docs: refactor codebase and update documentation
- Update installation command from `go get` to `go install` in README.md

Signed-off-by: appleboy <appleboy.tw@gmail.com>
v1.3.3
2024-10-04 22:19:13 +08:00
appleboy dff06f164a docs: improve CI/CD pipeline and test reliability
- Update Docker image source to `ghcr.io/appleboy/drone-jenkins` in README.md

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 22:16:58 +08:00
appleboy 895becb9a7 docs: update README badges and improve documentation
- Add lint and testing badge to the README
- Remove build status badge from the README
- Remove Docker pulls badge from the README
- Remove microbadger badge from the README

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 22:11:42 +08:00
appleboy 5344ca212b ci: improve test coverage and CI workflow reliability
- Remove `macos-latest` from the OS matrix in the lint workflow

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 21:05:40 +08:00
appleboy b370179bda refactor: refactor codebase for improved compatibility and efficiency
- Replace `ioutil.ReadAll` with `io.ReadAll` in `jenkins.go`
- Ignore the return value of `godotenv.Load` in `main.go`
- Ignore the return value of `godotenv.Overload` in `main.go`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:34:57 +08:00
appleboy d9f9a4ddc5 ci: refactor CI pipeline to remove Docker Hub dependencies
- Remove Docker Hub login step
- Remove Docker Hub image reference

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:32:00 +08:00
appleboy 51db9357f0 ci: refactor and optimize CI/CD pipeline
- Update Docker login action from version 2 to version 3 in GitHub workflow

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:30:58 +08:00
appleboy 0326a42ccb chore: upgrade Go version and dependencies in project
- Remove Go 1.21 from the lint workflow
- Update Go version to 1.22 in go.mod
- Upgrade dependencies: `godotenv` to v1.5.1, `testify` to v1.9.0, `cli` to v1.22.15
- Add new indirect dependencies: `go-md2man/v2`, `go-spew`, `go-difflib`, `blackfriday/v2`, `yaml.v3`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:22:51 +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
appleboy f932a0ef24 build: refactor build system and update formatting tools
- Change `GOFMT` tool from `gofmt` to `gofumpt`
- Remove DockerHub deployment configurations
- Add detection and setup for Go environment variables
- Add conditional flags and executable naming based on OS
- Update `fmt` and `fmt-check` targets to use `gofumpt`
- Remove `lint`, `misspell-check`, and `misspell` targets
- Update `test` target to remove dependency on `fmt-check`
- Change `install` and `build` targets to use `GOFILES` instead of `SOURCES`
- Update `$(EXECUTABLE)` target to output to `bin/`
- Remove various `release` and `docker` related targets

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:21:32 +08:00
appleboy 5122d14617 ci: enhance CI with multi-OS and Go version testing
- Rename `testing` job to `test`
- Add matrix strategy to run tests on multiple OS and Go versions
- Replace `actions/checkout@v4` with `actions/setup-go@v5` for setting up Go
- Add caching for Go build and module files using `actions/cache@v4`
- Change test command from `make test` to `go test -v -covermode=atomic -coverprofile=coverage.out`
- Add flags to `codecov/codecov-action@v4` for OS and Go version

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:21:23 +08:00
appleboy 65d16c52a3 chore: improve code quality and testing robustness
- Add hadolint configuration file with rules DL3018 and DL3008 ignored

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:15:35 +08:00
appleboy 86574d9456 build: consolidate Dockerfiles for multi-architecture support
- Add a new Dockerfile for multi-architecture support using Alpine 3.20
- Remove Dockerfile for linux.amd64
- Remove Dockerfile for linux.arm
- Remove Dockerfile for linux.arm64
- Remove Dockerfile for windows
- Remove Docker manifest template file

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:15:23 +08:00
appleboy 1cbab46f5c ci: add CI/CD workflows and dependency management
- Add funding configuration file with multiple supported platforms
- Add Dependabot configuration for GitHub Actions and Go modules with weekly updates
- Add CodeQL analysis workflow for Go language
- Add Docker image build and push workflow for multiple platforms
- Add GoReleaser workflow for automated releases on tag push
- Add linting and testing workflow with Go setup, Dockerfile linting, and Codecov integration

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 15:13:35 +08:00
appleboy 7c4ff53a64 chore: clean up obsolete configuration files
- Remove `.drone.jsonnet` file
- Remove `.drone.yml` file
- Remove `.editorconfig` file
- Remove `.revive.toml` file
- Remove `pipeline.libsonnet` file

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-10-04 14:28:23 +08:00
Bo-Yi Wu 4d6399606b chore: upgrade to go1.15
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-09-26 12:40:20 +08:00
Bo-Yi Wu 118b8f9b35 chore: upgrade to go1.14 2020-07-18 09:48:04 +08:00
Bo-Yi Wu daf0401e30 chore: load env from /run/drone/env path 2020-07-18 09:46:57 +08:00
Bo-Yi Wu 685cc312e3 chore(makefile): remove GOPACKAGE variable 2020-02-01 17:58:28 +08:00
Bo-Yi Wu cac1337e91 docs: update diff format 2019-10-19 10:17:11 +08:00