Giriş
Açıklaması şöyle
FreestyleFreestyle build jobs are general-purpose build jobs, which provide maximum flexibility. It can be used for any type of project.Multi-configurationThe multi-configuration project allows users to run the same build job on different environments. It is used for testing an application in different environments.FolderThis project allows users to create folders to organize and categorize similar jobs in one folder or subfolder.Multi-branch PipelineThis project type lets you implement different Jenkinsfiles for different branches of the same project.PipelineThis project runs the entire software development workflow as code. Rather than creating several jobs for each stage of software development, you can now run the entire workflow as one code.GitHub OrganisationThis project scans your entire GitHub organization and creates Pipeline jobs for each repository containing a Jenkinsfile.
1. Freestyle
Örnek
Şöyle yaparız
Örnek
Şöyle yaparız
Click New item, give it a name (I called mine “continuous-integration”), and then select Freestyle Project. You will be presented with a bunch of option, the following settings should be set:- Under Source Code Management, select git, then enter the URL of your GitHub repo as well as the branch you would like Jenkins to listen to.- Under Build Triggers, select GitHub hook trigger for GITScm polling- Under Build Environment, select Provide Node & npm bin/ folder to PATH. Select your node installation under NodeJS Installation- Under Build, add the build step Execute Shell and in the prompt enter:npm installnpm test
Şeklen şöyle
Açıklaması şöyle
How do you create a multi-branch Jenkins pipeline?In a Multi-branch Pipeline project, Jenkins automatically discovers, manages, and executes Pipelines for branches that contain a Jenkinsfile in source control.To create a Multi-branch Jenkins Pipeline1. Open Jenkins Dashboard and create a new item by clicking “New Item”2. Enter the project name, and from the options select “Multi-branch pipeline”3. Once you confirm, select the repository location, and branch source and add the branch source credentials.4. After saving the project, Jenkins automatically creates new Multibranch Pipelines for repositories5. Then to connect to the GitHub repo, we need the HookURL6. To get this URL from the repository settings, add this HookURL to the Webhooks section7. Once the jobs are created, Jenkins will automatically trigger the build.
Bir video burada. Açıklaması şöyle. Yani aynı pipeline farklı branch'ler için otomatik olarak yaratılıyor ve çalıştırılıyor.
A multi-branch pipeline is a concept of automatically creating Jenkins pipelines based on Git branches. It can automatically discover new branches in the source control (Github) and automatically create a pipeline for that branch. When the pipeline build starts, Jenkins uses the Jenkinsfile in that branch for build stages.
SCM (Source Control) can be Github, Bitbucket, or a Gitlab repo.
Benzer bir açıklama şöyle
Jenkins Pipeline Vs. Multibranch Pipeline5. Pipeline
A normal pipeline job is meant for building a single branch from the SCM and deploy to a single environment.
A multibranch pipeline is meant for building multiple branches from a repository and deploy to multiple environments if required.
Docker image deployment için kullanılır
Örnek
Açıklaması şöyle
Now go back to the dashboard and create a new item and select Pipeline.Under Build Triggers, select Build after other projects are built, enter the name of your previous CI item, and select Trigger only if build is stable. That way we will only deploy the application if the previous tests succeeded.
Şeklen şöyle
Açıklaması şöyle
Next under Pipeline, select Pipeline script and enter the following script. Make sure to change the environment variables at the top of the script. Change registry (repository) and gitUrl/gitBranch to your repositories, and change the registryCredential variable to the id of your Docker Hub credentials that you created earlier.
Şöyle yaparız
pipeline {environment {registry = 'christophergustafson/node-application'registryCredential = 'dockerhub'dockerImage = ''gitBranch = 'main'gitUrl = 'https://github.com/ChristopherGustafson/tutorial-app.git'}agent anystages {stage('Cloning our Git') {steps {git branch:gitBranch, url:gitUrl}}stage('Building Docker Image') {steps {script {dockerImage = docker.build registry + ":$BUILD_NUMBER"}}}stage('Deploying Docker Image to Dockerhub') {steps {script {docker.withRegistry('', registryCredential) {dockerImage.push()}}}}stage('Cleaning Up') {steps{sh "docker rmi --force $registry:$BUILD_NUMBER"}}}}
Hiç yorum yok:
Yorum Gönder