Integrate IBM Watson with Jenkins
- Create an IBM Watson service instance and ensure it can produce output relevant for your Jenkins trigger, such as sentiment analysis results.
- Secure your Watson API key, as it is required for programmatic access.
Setup the Watson Analysis Logic
- Develop a script or application that performs the Watson analysis and evaluates results. Depending on the outcome, this script should exit with a specific code.
- If results meet conditions for triggering a build, have the script exit with '0'. Otherwise, use a non-zero exit code.
Jenkins Configuration
- Install the Jenkins "Build on Result" plugin if available, or use the "Post-Build Actions" feature.
- Set up a Jenkins job with a "Trigger Builds Remotely" option. Configure it to listen for a specific token or result file containing analysis outcomes.
Script Example
import requests
response = requests.get('https://api.ibm.com/watson', params={'apikey': 'YOUR_API_KEY'})
result = response.json()
if result['status'] == 'desired_condition':
exit(0)
else:
exit(1)