Adding Your First Pipeline

While all Wercker applications ship with the build pipeline out of the box, this isn’t always enough. You may also need to add custom pipelines come into play. With pipelines, automating a build process in stages or when code changes is a nearly painless process, and takes only minutes to set up.

pipelines1.png

This page walks through an example of setting up a pipeline in Wercker.

Getting Started

To get started, let's take a look at an example wercker.yml file with build and deploy pipelines already defined.

box: ubuntu
build:
 steps:
   - script:
     name: step one
     code: echo "Step One"
   - script:
     name: step two
     code: echo "Step Two"
   - script:
     name: step three
     code: echo "Step Three"
   - script:
     name: step four
     code: echo "Step Four"
   - script:
     name: step five
     code: echo "Step Five"
deploy:
 steps:
   - script:
     name: step one
     code: echo "Step One"
   - script:
     name: step two
     code: echo "Step Two"
   - script:
     name: step three
     code: echo "Step Three"
   - script:
     name: step four
     code: echo "Step Four"
   - script:
     name: step five
     code: echo "Step Five"

While it’s not much of a CI/CD workflow, the above config file should be enough to demonstrate how defined pipelines can work independently of one another, and are only executed when configured directly within a Wercker application.

Creating the Pipeline

pipelines2.png

Since Wercker automatically creates the build pipeline when you import your application, half of the work is done, but what about the other half? To run the deploy pipeline, we first must create a new pipeline within our application's Wercker dashboard.

This can be accomplished by clicking on "Add new pipeline" under the "Workflows" tab. While the Name and YML Pipeline Name inputs should be self-explanatory, the Hook Type might not be as clear. This value is used to decide when to run the pipeline: Default runs whenever you tell it to run, and can be automated using workflows, and Git Push runs whenever you push new code up to designated branches.

Add Pipeline to a Workflow

pipeline3.png

Once we've created our pipeline, we then need to add it to a workflow. (This step is only necessary if the Default hook type was chosen.) To do this, you can either start a new workflow, or (in the case of a standard build -> deploy process), you can configure it to run after an existing step.

pipeline4.png

As you can see from the screenshot above, our demo deploy pipeline has been configured to run when the build pipeline finishes. It is important to note that with workflows, your configured pipelines can be executed serially or in parallel under any number of conditions, allowing for incredibly complex build processes with minimal setup.

pipeline5.png

Next Steps

That's it!

You've successfully created your first Wercker pipelines. On your next build, you should see your new pipeline run immediately after the build step. While this example is fairly simplistic, you can see just how powerful it can be for automating multiple builds, deploying code and assets to different servers, and running branch-specific scripts.

pipeline6.png

So what's next? How can we take things further?

At their core, Wercker pipelines are just isolated build scripts that can be run independently of one another. This means that however you design your build process (the box you run, environment variables you define, services you spin up, etc.), the same level of configuration can be achieved for any additional pipeline. Check out the Per-Pipeline Containers documentation for more information.