# DevOps Tools (Jenkins Pipeline using Jenkins File write Own Script && get from SCM(source code management))
###### tags: `Devops` `K8s` `Docker` `Jenkins` `Ansible` `Terraform`
## Jenkins pipeline
```java=
Jenkins's pipeline is a way or a process to build CI/CD process automatically.
To implement pipeline in Jenkins we use Jenkinsfile.
Jenkinsfile > pipeline as a code
```
Start the Jenkins:


Install the pipeline plugin as we use to install pulgins before.
-> Manage Jenkins -> Manage Plugins

Go the installed plugins and check weather you have pipeline pulgin. when we installed default plugins its automatically installed. If you cant find you can go to Available section and install.

So I already have pipeline plugin in the installed plugin list:

Now plugin is installed we can go to create a new job.

Write the Project name and select the pipeline. You can be able to see the Pipeline when you install plugin.

Click Ok

Now Create or get jenkins file in the pipeline section
you can create you own script or choose from SCM(source code management e.g. github, gitlab or any other source code management)

Now we can choose pipeline script.
Note: Jenkins file can be written using two ways of syntax Declarative and Scripted both are written with Groovy but have different structure.
Scripted: Old method
Declarative: New Method
Choose the Scripted pipeline and click on that and you can see the sample of jenkins file.

Lets Chcek the most simplest Jenkins Script:
Hello world script:

auto script genetor in jenkins:
click on the pipeline syntax.

you can see this kind of window.

select the dropdwon menu and choose any option you want to create script.


Anyhow, we can go back to our hello world script and click -> apply -> save

Now the job is save click on the Build now


Check with the consol output.

Lets add more stages and test again.
After editing the script -> Apply -> Save

Now we can build again and we can see all the stages are showing.

Lets check the console output:

## How to get the Jenkins File from SCM.
Create Repository on Github.

Add jenkinsfile in repository:
Create a file add the script and commit the file.

copy the link

goto the already created project config. You may create a new project or use existing project.

Goto -> Advanced Configuration -> Select pipeline script from SCM



