Use this helper function if you need to trigger Jenkins multibranch build when changes successfully mered to master.
- Generate Jenkins User's Token:
Click your name on the top right corner on every page, then click "Configure"
to see your API token
- Set necessary values in serverless.yml file:
environment:
TRIGGER_BRANCHES: master,stage,etc,comma,separated
REGION: ${self:custom.region}
URL_DEFAULT_TTL: ${self:custom.url_default_ttl}
JENKINS_USER: <username>
JENKINS_USER_TOKEN: <token>
JENKINS_URL: https://<jenkins_url>
JENKINS_PIPELINE_NAME: <multibranch_pipeline_name>
- Install Serverless Framework:
npm install serverless --global
serverless plugin install --name serverless-python-requirements
- Configure aws cli (use your preferred method):
aws configure --profile dev
export AWS_PROFILE=dev;
-
Deploy an app:
serverless deploy
-
Grab endpoint URL:
serverless info
# endpoints:
# POST - https://4-20-time.execute-api.us-west-2.amazonaws.com/dev/trigger
- Go to GitHub repository settings and create a Webhook:
Payload URL = <lambda url>
Content type = application/json
Let me select individual events:
Pull requests;
Pushes;
- Check the setup (tail Lambda logs):
serverless logs --function trigger --tail