Jenkins

  • Agents in Jenkins
    • An agent is a machine or a container that connects to Jenkins controller and execute tasks as directed by the controller.
    • Controller administrate the connections and tooling for the container or agent.
    • Agent can be bare metal, virtual or can be on cloud.
    • Any machine that can run Java can be an agent for Jenkins controller.
    • Agents provide more security and better performance.
  • Create Agent Node in Jenkins.
    • To create an Agent node In Jenkins, go to manage Jenkins and click on nodes.
    • Click on new node.
    • Give it a name, description, and root directory.
    • Add labels based on your usage.
    • Add launch methods and its credentials.
    • Host key verification strategy
      • JDK and port options
    • Number of executors of an agent is based on CPU’s Available on your machine.
    • For non verifying verification strategy as Host Key verification strategy we just need credentials for launching agents via SSH.
    • Using SSH keyfile for launching agents via ssh.
      • We use known hosts file strategy as Host key verification strategy here.
      • Create the following Directory
        • mkdir -p /var/lib/jenkins/.ssh
      • Copy entries for your ssh host in the known_hosts directory
        • ssh-keyscan -H hostname >> /var/lib/jenkins/.ssh/known_hosts
      • Change the ownership of .ssh folder to jenkins user
        • chown -R jenkins /var/lib/jenkins/.ssh
  • Creating pipeline In Jenkins.
    • We create, a pipeline Jenkins to define a series of steps To perform an action Like, pulling the files from git Repository And performing operations using them.
    • To create a pipeline Select new item and then pipeline from the Jenkins dashboard.


    • Provide its definition either in text format or From SCM, like git repository.
    • Change the BRANCH and give path to script file If given from repository.


    • Create credentials in Jenkins for the PostgresDB For example, in the Given repository We are executing scripts from flyway

      • You will use the id of these in pipline
    • Create a database with name, flyway and run the pipeline.

Comments

Popular posts from this blog

Setup Flyway,Postgres in Jenkins using Docker

Setup Devops in AWS

Using SSH keyfile for launching agents via ssh