The configuration
Although task performed by this step may look straightforward – we just need to download jokes and display them, it may be also useful to introduce a little bit of flexibility by allowing some parameters to be configurable. First of them is API host URL, one may want to use a different one than public chucknorris.io e.g. self-hosted instance due to privacy reasons. All the backend components of chucknorris.io are open source so it shouldn’t be a problem.
Secondly, we may want to bulgaria phone number customize jokes category. One may prefer some particular one. There is a query parameter in API for that.
Configuration parameters are specified using step inputs. They appear as form fields in workflow editor GUI and are injected as environment variables to the build. Newly generated step contains sample input. We can base on it when adding actual inputs. After customization, inputs section should look like this:
Input names (category and api_base_url) are written using lower snakecase.
api_base_url is marked as required, this fact will be reflected in the workflow editor.
api_base_url has a default value set to https://api.chucknorris.io so users don’t need to specify it explicitly.
OK, we have inputs defined. Now we can try to read their values. Fortunately, Bitrise provides steputils library which does all the work for us. We only need to define data structure for config:
How to Add Chuck Norris Jokes to Bitrise Build Logs
-
- Posts: 16
- Joined: Mon Dec 23, 2024 3:52 am