Hi everybody,
Last time we have seen what is Pipeline concepts including scripted and declarative pipeline methods.Today we will see how to create easily a declarative pipeline using Blue ocean tool.It will allow us to generate a workflow without needing advanced scripting skills.

what’s blue ocean?

Blue Ocean is graphical user interface making it easier to define continuous delivery pipelines. To build your pipelines you will use an integrated editor. You will be able to check their execution visually and to detected problems at any step of the workflow in order to solve then quicker.

  • starting installation of blue ocean

for our case we will add it directly to our Jenkins master using the plugin manager
You also have some interesting info at https://www.jenkins.io/doc/book/blueocean/getting-started/

  • wait for installation

create our 1st pipeline using Blue ocean

  • Now we have installed blue ocean we will start it from Jenkins dashboard

  • here we are ,we can now access to a GUI to manage pipeline creation execution and edition

using blue ocean GUI

  • select your git environment ( for this case GitHub

add a Git repository

  • to continue the pipeline creation we have to add a git repository ( if you dont have it you must create it,in this example we will use github )

  • to allow Jenkins to communicate with Github we will define an access token from Github


  • select your organization

  • select the repository to create your pipeline

  • if no Jenkinsfile found inside, blue ocean will ask to create one

  • in this part you will selected (and edit when you want) all steps of your pipeline thanks to pre-configured tools

  • Once configured you can start your pipeline an see the result

  • it is possible to check each log of each steps by clicking on it, also we have access to other in the tool bar  like “tests” and “artifacts”(where we can download output of the pipeline and see all its execution step by step)

update file from GitHub repository

when we check the log below we can see that it is connecting to Github to perform the workflow using the Jenkins file

Branch indexing

Connecting to https://api.github.com using adminjnks/****** (GitHub Access Token)

Obtained Jenkinsfile from 922c2521cbe0c42b728957a2458aed7216a9e6a2

Running in Durability level: MAX_SURVIVABILITY

[Pipeline] Start of Pipeline

[Pipeline] node

Running on Jenkins in /var/lib/jenkins/workspace/TSTPPL_main

[Pipeline] {

[Pipeline] stage

[Pipeline] { (Declarative: Checkout SCM)

[Pipeline] checkout

The recommended git tool is: NONE

using credential github

> git rev-parse --is-inside-work-tree # timeout=10

Fetching changes from the remote Git repository

> git config remote.origin.url https://github.com/admjenkins/TSTPPL.git # timeout=10

Cleaning workspace

> git rev-parse --verify HEAD # timeout=10

Resetting working tree

> git reset --hard # timeout=10

> git clean -fdx # timeout=10

Fetching without tags

Fetching upstream changes from https://github.com/admjenkins/TSTPPL.git

> git --version # timeout=10

> git --version # 'git version 2.27.0'

using GIT_ASKPASS to set credentials GitHub Access Token

> git fetch --no-tags --force --progress -- https://github.com/admjenkins/TSTPPL.git +refs/heads/main:refs/remotes/origin/main # timeout=10

Checking out Revision 922c2521cbe0c42b728957a2458aed7216a9e6a2 (main)

> git config core.sparsecheckout # timeout=10

> git checkout -f 922c2521cbe0c42b728957a2458aed7216a9e6a2 # timeout=10

> git branch -a -v --no-abbrev # timeout=10

> git branch -D main # timeout=10

> git checkout -b main 922c2521cbe0c42b728957a2458aed7216a9e6a2 # timeout=10

Commit message: "Added Jenkinsfile"

> git rev-list --no-walk cb0ef1ff70cfb9c1dc25662d420620d608bcf200 # timeout=10

Cleaning workspace

> git rev-parse --verify HEAD # timeout=10

Resetting working tree

> git reset --hard # timeout=10

> git clean -fdx # timeout=10

[Pipeline] }

[Pipeline] // stage

[Pipeline] withEnv

[Pipeline] {

[Pipeline] withEnv

[Pipeline] {

[Pipeline] stage

[Pipeline] { (TEST)

[Pipeline] echo

test fisrt stage

[Pipeline] }

[Pipeline] // stage

[Pipeline] stage

[Pipeline] { (BUILD FOLDER)

[Pipeline] sh

+ mkdir /home/jenkins/PPLTESTING

[Pipeline] }

[Pipeline] // stage

[Pipeline] stage

[Pipeline] { (CREATE FILE)

[Pipeline] sh

+ touch /home/jenkins/PPLTESTING/filecreatedPPL

[Pipeline] }

[Pipeline] // stage

[Pipeline] }

[Pipeline] // withEnv

[Pipeline] }

[Pipeline] // withEnv

[Pipeline] }

[Pipeline] // node

[Pipeline] End of Pipeline




GitHub has been notified of this commit’s build result




Finished: SUCCESS

edit Jenkins file from Source code repository

By editing the Jenkinsfile in the repository we can also update the Pipeline with the text editor.

  • Once done you select if commit will be performed on the main branch or on another branch

add parallel steps

  • with Blue ocean you also have the possibility to add parallel steps for your pipelines to check for example software version or add a file-watcher

conclusion

Now you are able to easily create and manage your pipelines with Blue ocean but bare in mind it doesn’t include every feature of Jenkins master interface.Next time we will check some pipeline use case and see how to use features like artifacts.
Feel free to visit dbi blogger’s and take a look on Cloudbees and Jenkins site.