Jenkins

In How many ways can we launch an agent in Jenkins?

  • Launch agent by connecting it to master.
    • Agent Connects to master
  • Launch agent via SSH
    • Controller initiates the connection to the SSH.

How do we login into AWS? How do we pass and login AWS in Jenkins pipelines or Jenkins file?

  • We can use assume role and get credentials.
  • We can use AWS plug-in to configure cloud. In the cloud, we can provide our AWS access key or secret key.
  • We can add our EC2 End point, region, et cetera
  • Now in Jenkins credential provider, we can give our username and provide key credentials.
  • This will give us a credential ID. We can use this credential ID in Jenkins pipelines.

Can we write git clone in pipeline?

  • No, we can use checkout instead.

What is the difference between scripted and declarative pipeline?

  • Declarative pipelines uses declarative model and scripted uses imperative model.Declarative breaks the stages into multiple steps.Scripted Does not require this.
  • Scripted pipelines permit developer to inject a code, declarative pipeline doesn’t.
  • Declarative, use a simple, but more strict syntax.

What is the shared file or shared library in Jenkins?

  • A shared library in Jenkins is a reusable collection of Google scripts that can be used by multiple Jenkins jobs. It allows code sharing.
  • Shared libraries are stored in git repositories.

How can we run job in slave nodes?

  • Open the job And configure it restrict in General section?
  • In label expression, enter the name of the slave and save it.
  • Click build now.

What is the use of labels in Jenkins pipeline?

  • Jenkins labels allows us to tag a slave node.
  • Labels represent a way of naming one or more slaves.
  • They are used to tie execution of a job to one or more nodes.Or to create lode balanced Jenkins solutions.

Where are credentials stored in Jenkins?

  • Credentials are stored in Jenkins in Home/secrets. Uses AES to encrypt and protect secrets.
    • General credentials can be used via environment .
    • pipeline {
      agent any
      environment {
      DB_CREDS=credentials('db-creds')
      }
  • Git credentials are stored in Git plug-in or credentials plug-in.
  • Generate a personal access token on your GitHub account And add to new credentials with username as your email and password as your access token.
    • Now you can use the ID of these credentials in your step.
    • git branch: 'master',
    • credentialsId: '12345-1234-4696-af25-123455',
    • url: 'ssh://git@bitbucket.org:company/repo.git'
What is a multi branch pipeline?
  • A multi BRANCH pipeline project type enables you to implement different Jenkins files for different branches of the same project. Jenkins automatically discoverers messages and execute pipelines for branches which contain a Jenkins file in source control.
  • Four multiple branches will have four different Jenkins file But at same location.
After creating an artefact where do we deploy an artefact from our project? Which directory do we store?
  • By default, artefacts are stored in Jenkins Home directory.
  • We can use a tool that can directly deploy from Jenkins Like build master. We can push to artefactory and then Build Master pulls from artefactory.
  • If we need to copy on our network, we can use a plug-in like copy artefact, which copies artefact between projects.

Comments

Popular posts from this blog

Setup Flyway,Postgres in Jenkins using Docker

Docker