Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Jenkins

Provision

  1. SSH to Jenkins server
  2. git clone https://github.com/project-sunbird/sunbird-devops.git -b sunbird-bootcamp
  3. cd sunbird-devops/deploy/jenkins
  4. sudo bash jenkins-server-setup.sh  ## This will install and setup Jenkins server
  5. After completion of the above script, open Jenkins in a browser by typing your domain name/Public IP:8080
  6. Enter the initial password  and choose install suggested plugins.
  7. Create a admin user by filling all the details and choose the default Jenkins URL.
  8. sudo bash jenkins-config-setup.sh  ## This will configure build, provision and deployment jobs in jenkins as well as download m2 repo
  9. Go to Manage Jenkins -> Manage Plugins -> Update Center -> Check restart after installation
  10. Create a jenkins vault password for private github account
    1. Goto http://<jenkins_domain>/credentials/store/system/domain/_/newCredentials
    2. Select username with password
    3. Give description as private repo and save
    4. Click the credential again and click update. Copy the ID.
  11. Configuring Jenkins variables
    1. Goto http://<jenkins_domain>/configure
    2. Navigate to Environment Variables section and add the following

      Code Block
      ANSIBLE_FORCE_COLOR = true
      ANSIBLE_HOST_KEY_CHECKING = false
      ANSIBLE_STDOUT_CALLBACK = debug
      hub_org = < docker hub organization eg: In sunbird/player image, sunbird is the hub_org> 
      private_repo_branch = < private repo branch where ansible hosts exist >
      private_repo_credentials = <id created in step 10>
      private_repo_url = < Github private repo url >
      public_repo_branch = jenkins-pipeline


    3. Go to Pipeline libraries section and add the following

      Code Block
      Name: deploy-conf
      Version: jenkins-shared
      Modern SCM -> Git
      Repo: https://github.com/project-sunbird/sunbird-devops.git


    4. Go to Mangaer Jenkins - > global security section and add the following

      Code Block
      Markup Formatter: Safe HTML


    5. Goto http://<jenkins_domain>/computer and click master → configure → add the following

      Code Block
      executors: 10
      Labels: build-slave


  12. Restart Jenkins 
    1. http://<jenkins_daomain>/reload


Info
titleNotes

Building maven projects may take time as it have to download lots of dependencies.

To As part of Workshop to speed up the process, we have already add steps in script to download the .m2 folder from Azure blob and  and keep it in /var/lib/jenkins/.m2

Bootstrap User

  1. Create directory /run/secrets as root using mkdir -p /run/secrets
  2. Copy the master user ssh-key (the one through which you can login to VM or which was generated while creating the VMs;  In our case it was as named as ops user)  to /run/secrets/ops_ssh_key
  3. Keep the private key for deployer user in /run/secrets/deployer_ssh_key and chown jenkins:jenkins /run/secrets/deployer_ssh_key
  4. sudo chown jenkins:jenkins /run/secrets/ops_ssh_key && chmod 400 /run/secrets/*
  5. Optional: Keep ansible vault password in  /run/secrets/vault-pass if the secrets.yml is encrypted and  chown jenkins:jenkins /run/secrets/vault-pass
  6. Run OpsAdministration/<module>/Core/Bootstrap  This will create deployer user(defined in ansible) with ssh_key(public_key defined in common.yml) which will be used for all jenkins jobs.

This page contains

Table of Contents