Friday, 28 February 2020

Jenkins 2 course pluralsight


Creating NewJob in Jenkins:

Freestyle - Configure Tab
SCM -> Give git link, username/password
Build -> Invoke top-leve maven target -> Goals compile (1st vid)
Build -> Invoke top-leve maven target -> Goals archive (2nd vid)
To archive:
Post build actions -> Archive the artifacts -> <give the path to archive. Note: jar will be in target path>
To Clean and Package:
Invoke top-leve maven target -> Goals clean package (3r vid)

Pipeline Job
Master will have executors. By default it can do 2 tasks and we can allocate more if we need.
Node - main block
parallel chrome:{runTests("Chrome")
}, firefox:{
} -> This is example of parallel. chrome just name. runTests is function. Only parallel is the keyword
Stage name: concurrency:1 -> Shows as stages. For example: We can give our own title for each block of code in pipline like checkout, compile, test and archive. It can also use concurrency option which is used when multiple build is triggered then only latest build will execute.
input - To introduce manual step and it don't require to be inside a node. It uses flyweight executor

Executors -> Flyweight (it don’t allocate node and there is no limit) and Heavyweight (it allocate node). Heavyweight does the actual execution

For e-mail - Try using mailhog docker

Jenkinsfile:
For using jenkins file use option "Pipeline script from SCM". Here we will have option for GIT
When using jenkins file, GIT groovy is not required. Instead give "checkout scm"

Pipeline advantages:
You can break jobs into several stages. This will help us to narrow down where it failed.
Ability to run parallel
If agent goes down pipeline will pause and start whereas freestyle will fail.

Parallel Job:
While running parallel job, if the job runs in same server in workspace it will create folder with name @2, @3 etc based on how many parallel we have
node statement will come inside the def statement.
Parallel code should be written first

Creating Node:
Manage Jenkins - New Node - Give name / check permenant agent checkbox
Give Remote Root Directory -> This should be unique for each agent
Labels -> The name can be used for pooling together agents
Launch method -> Java webstart (JNLP file for Windows and SSH for Linux)

Problems -> Password less SSH connectivity. Paste Private key in Jenkins Credentials Manager, add the Public key to authorized key of the server
Java not in path ->  /usr/local/bin/java (Created symbolic link)



Getting Started with Jenkins 2
By Wes Higbee

No comments:

Post a Comment

Golang - Email - Secure code warrior

 package mail import ( "net/smtp" "gobin/config" ) var ( emailConfig config.Email ) type Mail struct { Destinati...