Triggering Code Manager with custom scripts
Custom scripts are a good way to trigger deployments if you can't use webhooks. For example, if you have privately hosted Git repositories, custom notifications, or existing continuous integration systems (like Continuous Delivery for Puppet Enterprise (PE)).
Triggering Code Manager with a webhook is simpler than using a custom script. If you can use a webhook, we recommend it.
To create a script that triggers Code Manager to deploy your
environments, you can use either the puppet-code
command or a
curl
statement that hits the Code Manager
API endpoints. We recommend using the puppet-code
command, if
possible.
After pushing new code to your control repo, run your script to trigger Code Manager to deploy your code.
The following instructions assume you've Set up Code Manager.
Scripting the puppet-code
command
The puppet-code
command can deploy environments from the command
line. You can use this command in custom Code Manager
scripts.
Using puppet-code
in Code Manager scripts is much the same as Triggering Code Manager on the command line. The benefit to using a
script is that you don't need to rebuild the commands from scratch each time, since they
are stored in scripts.
Build your desired puppet-code
command with the relevant
action, environment (or --all
for all environments),
custom puppet-code.conf
settings, and other options.
Then, incorporate the command into your complete script.
After pushing new code to your control repo, run your script to trigger Code Manager to deploy your code.
Scripting deploys
curl commands
The Code Manager API deploys
endpoint can trigger code deployments. You can use a curl command in your custom scripts to
hit this endpoint.
Calling the deploys
endpoint in a script is similar to
forming a one-time call to the endpoint. By storing commands in scripts, you don't need to
rebuild the commands from scratch each time.
Build your desired curl command with the relevant URI path, parameters, and authentication, as described in POST /v1/deploys. Then, incorporate the command into your complete script.
Scripting deploys/status
curl commands
The Code Manager API deploys/status
endpoint can check a deployment's status. You can use a curl
command in your custom scripts to hit this endpoint.
Calling the deploys/status
endpoint in a script is
similar to forming a one-time call to the endpoint. By storing commands in scripts, you
don't need to rebuild the commands from scratch each time.
Build your desired curl command with the relevant URI path, parameters, and authentication, as described in GET /v1/deploys/status. Then, incorporate the command into your complete script.