{"id":20493639,"url":"https://github.com/code-lucidal58/jenkins_cheatsheet","last_synced_at":"2026-03-10T03:31:26.626Z","repository":{"id":88633387,"uuid":"372710998","full_name":"code-lucidal58/jenkins_cheatsheet","owner":"code-lucidal58","description":"Jenkins Cheatsheet","archived":false,"fork":false,"pushed_at":"2021-06-07T10:44:25.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-16T05:55:44.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-lucidal58.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-01T05:26:28.000Z","updated_at":"2021-06-07T10:44:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"02fbd127-f089-48c0-8c65-68a1743ab71d","html_url":"https://github.com/code-lucidal58/jenkins_cheatsheet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-lucidal58%2Fjenkins_cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-lucidal58%2Fjenkins_cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-lucidal58%2Fjenkins_cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-lucidal58%2Fjenkins_cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-lucidal58","download_url":"https://codeload.github.com/code-lucidal58/jenkins_cheatsheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242075255,"owners_count":20068224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T17:36:02.826Z","updated_at":"2026-03-10T03:31:21.597Z","avatar_url":"https://github.com/code-lucidal58.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jenkins Cheatsheet\n[Jenkins](https://www.jenkins.io/) is an open source automation server. It is majorly used for CICD pipelines. \n\nI am writing this cheatsheet while learning about Jenkins from multiple platforms like Udemy, Pluralsight, LinkedIn Learning and multiple articles.\nDownload Jenkins using homebrew in MacOS and Linux, and exe file from the official website for Windows.\n\n## Installation of Jenkins\n\n### Prerequisites\n* Install Docker and Docker compose\n* Pull docker images using `docker pull jenkins/jenkins`. \n\n### Steps for jenkins installation using docker\n* Create a docker compose file that has the following content. `volumes` should have the path where the data from the container is to be stored. \nDocker compose is used for making the container persistent. \n```\nversion: '3'\nservices:\n  jenkins:\n    container_name: jenkins\n    image: jenkins/jenkins\n    ports:\n      - \"8080:8080\"\n    volumes:\n      - $PWD/jenkins_home:/var/jenkins_home\n    networks:\n      - net\nnetworks:\n  net:\n```\n\n* Create a directory `jenkins`. Place the docker compose file in it. \n* Create a new directory named `jenkins_home` inside `jenkins` dir. \n* Inside `jenkins` dir, do the following:\n  * `sudo chown 502:502 jenkins_home -R` give permissions to write to the folder.\n  * `docker-compose up -d` spin up the container\n  * `docker logs -f jenkins` gives you password\n\n* Hit localhost:8080 in a browser and login using this password.\n* The next screen asks for which plugins to install. Choose custom or recommended install (as per your wish). This takes a while.\n* After installation is complete, Jenks will ask you to create the first admin account. Assign username and password to the admin account. It will also ask for Jenkins URL. Preferrable leave as it is.\n* Once setup is complete, Jenkins might ask you to login using the admin credentials.\n\nTo start a container, `docker-compose start` and to stop it use `docker-compose stop`.\nTo restart `docker-compose restart jenkins`\nTo delete the container, `dcoker-compose down`. This will not delete the container data.\n\n## Jenkins UI\n* `New Item`: Create a new jenkins job. This has a number of templates.\n* `People`: List of people who can access this account along with their permission levels.\n* `Build History`: History of builds. Very intuitive :P\n* `Credentials`: Manage credentials to be used in the jenkins jobs\n* `Manage Jenkins`: Manage the jenkins account.\n\n### Creating First Job\n* Click on `New Item`. Give a name to this job and select Freestyle Project.\n* Under `Build` section, there is an option `Execute shell`. This will be executed in the same shell as `docker exec -ti jenkins bash` i.e. the container's shell.\n* A text box appears. Here type `echo Hello World`. And save.\n* On the left side, there will be an option `Build Now`. This will trigger the job and you can see the output in `Console Output` option on the left in the build's page.\nReconfigure the job by clicking `Configure` in the jobs page. Please take not of the words `jobs` and `builds`. Jobs produce builds. In the place you entered shell script, you can use other commands or env variables compatible to the container shell, like `date, who ami, etc`. Few examples are as follows:\n```shell\nNAME=aanimish\necho \"Hello aanimish. Current date is $(date)\"\necho \"Hello aanimish. Current date is $(date)\" \u003e /temp/data\n```\nThe file written in the last line resides in the container.\n\n###\nYou execute a script file in a job, the file should be present in the container. The Jenkins container does not vi ninstalled in it. To move a file from local system,\nto the container use `docker cp \u003cfilepath in local system\u003e jenkins:\u003cfull filepath in container\u003e`. For example, `docker cp script.sh jenkins:/tmp/script.sh`. \n\nThe script might need parameters from the user. To add parameters to the job, go to `Configure`. Under the general tab, there must be an option similar to `This \nproject is parameterised`. Here, the parameters name, default value and description is specified. There a number of different data type variables that can be \ndefined. Most commonly used to `string type`. Adding parameters, change the `Build` option in the left side of the job changes to `Build with Parameters`.\n\nTo create a list parameter, choose `Choice Parameter`. This creates a dropdown from the user. Mention each choice in a new line while adding parameters. \nWhile setting boolean parameters, there is a checkboc `Default Value`. If checked, the default value will be True, otherwise no default values. Boolean parameter is shown as checkbox to the user. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-lucidal58%2Fjenkins_cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-lucidal58%2Fjenkins_cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-lucidal58%2Fjenkins_cheatsheet/lists"}