Jenkins
Blue Ocean
Creating a Pipeline
In this guide, we'll walk through the process of creating a new pipeline using Blue Ocean. Follow the step-by-step instructions below to set up your pipeline and automatically generate a Jenkinsfile without any manual configuration.
Step 1: Start a New Pipeline
- Click the New Pipeline button.
- Choose where your code is stored. For this example, select GitHub and then choose the appropriate organization.
Note
If you are authenticating for the first time, you'll need a personal access token from GitHub (or your respective code host). Click the option to generate the token and provide it when prompted.
Step 2: Select Your Repository
For this demonstration, select the GoWebApp sample repository where our pipelines are executed.
Step 3: Create and Configure the Pipeline
- Click Create Pipeline.
- Give the pipeline a name; for example, GoWebApp.
- Click Save. You will see a notification that no Jenkinsfiles were found in the repository, which means you can continue to create one via the UI.
Step 4: Add Pipeline Stages and Steps
Click the plus button to add a stage and label the stage (for example, "dev").
Click Add Step and select Shell Script.
Enter the following command, which is identical to the one previously used in the Jenkinsfile for running tests:
go test ./.
Click the back button. You will then be prompted to commit the Jenkinsfile to the repository.
Click Save and Run.
Once you commit, you can verify via GitHub that the Jenkinsfile has been created automatically.
The Automatically Generated Jenkinsfile
The Jenkinsfile generated by Blue Ocean looks similar to the following:
pipeline {
agent any
stages {
stage('dev') {
steps {
sh 'go test ./.'
}
}
}
}
This Jenkinsfile runs the test command, ensuring that the pipeline functions properly without requiring manual Jenkinsfile creation.
Step 5: Review the Pipeline Dashboard
Return to the Jenkins interface, where you can see your pipeline with all its defined steps.
The visual representation of pipeline steps in Blue Ocean makes it much easier to manage and understand compared to manually editing a Jenkinsfile.
That concludes this guide on creating a pipeline with Blue Ocean. Happy coding, and we'll see you in the next lesson!
Additional Resources
Watch Video
Watch video content