{"id":14984658,"url":"https://github.com/colinbut/jenkins-pipelines","last_synced_at":"2025-04-10T21:20:50.296Z","repository":{"id":56862593,"uuid":"259344493","full_name":"colinbut/jenkins-pipelines","owner":"colinbut","description":"A collection of different types of Jenkinsfile (Pipeline as Code)","archived":false,"fork":false,"pushed_at":"2024-08-26T18:18:38.000Z","size":125,"stargazers_count":15,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T18:49:38.086Z","etag":null,"topics":["groovy","jenkins","jenkins-ci","jenkins-pipeline","jenkinsfile"],"latest_commit_sha":null,"homepage":"","language":"Groovy","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/colinbut.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":"2020-04-27T14:14:24.000Z","updated_at":"2024-07-31T10:24:39.000Z","dependencies_parsed_at":"2024-09-25T00:30:26.539Z","dependency_job_id":null,"html_url":"https://github.com/colinbut/jenkins-pipelines","commit_stats":{"total_commits":65,"total_committers":1,"mean_commits":65.0,"dds":0.0,"last_synced_commit":"f665105f48a191a572103c0f884b0a67bcb487d3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fjenkins-pipelines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fjenkins-pipelines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fjenkins-pipelines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fjenkins-pipelines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colinbut","download_url":"https://codeload.github.com/colinbut/jenkins-pipelines/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248298885,"owners_count":21080424,"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":["groovy","jenkins","jenkins-ci","jenkins-pipeline","jenkinsfile"],"created_at":"2024-09-24T14:09:28.615Z","updated_at":"2025-04-10T21:20:50.269Z","avatar_url":"https://github.com/colinbut.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jenkins Pipelines\n\nThe purpose of this project is for me to collect and hold a \"library\" of different Jenkins Pipelines. It also demonstrates numerous different ways to implement the\npipelines.\n\nMost noticeability:\n\n- Declarative Style\n- Scripted Style\n- Using a __Jenkins Shared Library__\n\nRather than configuring Jenkins Build Job configuration on the Web UI directly, code them in code files (`.groovy`) based on the Groovy DSL Syntax. This feature \nshowcases the `Pipeline As Code` philosophy.\n\n## Pipeline\n\nThis project does not aim to demonstrate every single pipeline feature it has but merely serves as a personal go to repo for examples \u0026 demonstration purposes.\nTo explore what Jenkins Pipeline Syntax has to offer fully, need to refer to its official documentation: https://www.jenkins.io/doc/book/pipeline/syntax/#post\n\n\n## Example App\n\nAs part of this demo jenkins pipelines library project, an example app is provided along with this for playing and testing the various different\nkinds of pipelines. It is a simple Java 8-Spring Boot app (one that is borrowed from one of my other personal side projects).\n\n## Declarative Pipelines\n\nDeclarative pipelines are a new syntax for Jenkins pipeline that came in later editions of Jenkins 2.0+\n\nThey aim to offer a more simplifed way of constructing pipelines as code which they follow a specific and yet rigid structure. Less flexible though.\n\ne.g.\n\n```groovy\npipeline {\n    agent any\n    stages {\n        stage(\"Compile\") {\n            steps {\n                sh \"./mvnw clean compile\"\n            }\n        }\n        stage(\"Unit Tests\") {\n            steps {\n                sh \"./mvnw test\"\n            }\n        }\n        stage(\"Integration Tests\") {\n            steps {\n                sh \"./mvnw verify\"\n            }\n        }\n        stage(\"Package\") {\n            steps {\n                sh \"./mvnw package -DskipTests=true\"\n            }\n        }\n    }\n    post {\n        always {\n            echo \"The build ${env.JOB_NAME} #${env.BUILD_NUMBER} has finished\"\n        }\n        failure {\n            echo \"The build ${env.JOB_NAME} #${env.BUILD_NUMBER} has failured\"\n        }\n        success {\n            echo \"The build ${env.JOB_NAME} #${env.BUILD_NUMBER} has successfully been built\"\n        }\n    }\n}\n\n```\n\n`pipeline` and `agent` derivatives are specific to Declarative syntax. Overall declarative syntax aims to 'declare' the state of the \npipeline.\n\n## Scripted Pipelines\n\nThe scripted pipelines examples have suffix `*-scripted.groovy` appended on to the file.\n\nScripted pipelines were the originally Jenkins pipeline syntax from the beginning of Jenkins 2.0+.\n\nThey are same as Declarative pipelines except that:\n- they don't follow a rigid structure\n- they don't have many constructs which many of them are actually specific to declarative syntax\n- they can contain `groovy` code directly as it is basically based on `groovy's dsl`.\n- due to its flexible nature (using groovy DSL to do logic etc...) it is more imperative than declarative syntax\n- they encompass a `node` block e.g.\n\n```groovy\nnode {\n    stage(\"Source\") {\n        git credentialsId: \"github_credentials\", url: \"https://github.com/colinbut/jenkins-pipelines.git\"\n    }\n\n    def maven = tool 'apache-maven-3.6.3'\n\n    stage(\"Compile\") {\n        sh \"${maven}/bin/mvn clean compile\"\n    }\n    stage(\"Unit Tests\") {\n        sh \"${maven}/bin/mvn test\"\n    }\n    stage(\"Integration Tests\") {\n        sh \"${maven}/bin/mvn verify\"\n    }\n    stage(\"Package\") {\n        sh \"${maven}/bin/mvn package -DskipTests=true\"\n    }\n}\n``` \n\n## Shared Library Examples\n\nFor the examples that uses a Shared Library, this project has close dependency on the [Jenkins Shared Library](https://github.com/colinbut/jenkins-shared-library.git) side project (another personal project of mines).\n\ne.g.\n\n```groovy\n@Library(\"my-shared-library\") _\n\nbuildJavaAppDockerFull(repo: \"jenkins-pipelines\", microserviceName: \"example-app\")\n``` \n\nThe above (taken from `013-java-app-docker-full-pipeline-shared-library.groovy`) loads in an already configured Jenkins Shared Library\nin Jenkins Configure System.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolinbut%2Fjenkins-pipelines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolinbut%2Fjenkins-pipelines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolinbut%2Fjenkins-pipelines/lists"}