Pipeline with Parameter
Last updated
Last updated
Now, we have configured another pipeline LF-test-pipeline-1 that's a little more complicated than the previous one, where we are deploying Minio. We've added three stages to this deployment, as shown in the screenshot below.
All the stages after ‘Configuration’ are the Deploy (Manifest) stage, same like the previous example, the stages use kubernetes manifest yaml/json files for deployment. Below a screenshot of the last stage configuration.
We have configured the last stage ‘deploy-minio’ which is dependent on the previous two stages.
As we can see, we have a Depends On option where we can select dependent stages. In our case it is ‘miniosecret’ and ‘minioservice’.
Apart from Configuration, all three stages use a text-based Manifest source, in this case Kubernetes yaml/json, as in the previous example for the simple pipeline.
The interesting part here is we will pass parameters for this pipeline. We want to deploy this Minio to a particular namespace in the spinnaker. We will configure these details in the Configuration stage.
Select the Configuration stage and PARAMETERS option as shown in the below screenshot.
Click the Add Parameter button and fill in the details we want to pass as a parameter. In our case, we are trying to pass namespace as a parameter. In our Spinnaker, we have two namespaces configured as develop and prod.
The Default Value we have kept as develop, we have also enabled ‘Show Options’, this enables us to select/change the Default Value and select the parameter we would like to pass before running the pipeline. After we have configured the parameters we will ‘Save Changes’.
Our Kubernetes yamls that we are using for the minio deployment uses pipeline expression ‘${parameters.namespace}’ for namespace which accepts the above parameter that we are passing.
We'll return to our pipeline page, as before.
We can see both the pipelines that we have configured so far. We will try to run the second pipeline from the screenshot that we see i.e., LF-test-pipeline-1.
Click on Start Manual Execution and the below screen will appear.
We can see the Namespace parameter that we have configured, we also see that by default we have ‘develop’ namespace selected. As we have configured another option for our Namespace parameter we can select the same by clicking on the downward triangle icon in the values window.
We can change the parameter depending on our requirement, once we have selected the desired Namespace, we will click Run to start the pipeline.
Passing parameters entirely depends on how the pipeline is configured. Also, there are other available options that can be passed as parameters which again depend on user/client requirements. It is not necessary that a pipeline has to be constructed to take parameters as input, however if the need arises, parameters can be passed to a pipeline like the above example.