{"id":19527428,"url":"https://github.com/angelcamposm/jenkins-shared-library","last_synced_at":"2026-05-19T19:06:45.677Z","repository":{"id":183673792,"uuid":"670548683","full_name":"angelcamposm/jenkins-shared-library","owner":"angelcamposm","description":"Jenkins Shared Library","archived":false,"fork":false,"pushed_at":"2023-08-17T13:37:12.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-26T02:28:08.134Z","etag":null,"topics":["devops","devsecops","in-toto","jenkins","jenkins-library","mvp","poc","security","slsa-framework","slsa-provenance"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/angelcamposm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2023-07-25T09:50:11.000Z","updated_at":"2023-08-16T00:45:12.000Z","dependencies_parsed_at":"2023-09-05T21:31:13.651Z","dependency_job_id":null,"html_url":"https://github.com/angelcamposm/jenkins-shared-library","commit_stats":null,"previous_names":["angelcamposm/jenkins-shared-library"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/angelcamposm/jenkins-shared-library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angelcamposm%2Fjenkins-shared-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angelcamposm%2Fjenkins-shared-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angelcamposm%2Fjenkins-shared-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angelcamposm%2Fjenkins-shared-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angelcamposm","download_url":"https://codeload.github.com/angelcamposm/jenkins-shared-library/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angelcamposm%2Fjenkins-shared-library/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266922972,"owners_count":24006987,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["devops","devsecops","in-toto","jenkins","jenkins-library","mvp","poc","security","slsa-framework","slsa-provenance"],"created_at":"2024-11-11T01:14:59.558Z","updated_at":"2026-05-19T19:06:40.642Z","avatar_url":"https://github.com/angelcamposm.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jenkins-shared-library\n\nThis Jenkins Shared Library is a MVP of a SLSA Provenance and in-toto attestation for Jenkins builds. \n\n\n## Jenkinsfile\n\n```groovy\n@Library('pipeline-library@master') _ \n\n// Import stateful classes from Jenkins shared library\nimport dev.slsa.Provenance\nimport edu.nyu.engineering.ssl.Envelope\nimport io.intoto.ResourceDescriptors.*\nimport io.intoto.ResourceDescriptor\nimport io.intoto.Statement\n\n// Create new instances\ndef Provenance provenance = new Provenance()\ndef FileResourceDescriptor fileRd = new FileResourceDescriptor()\ndef GitRepositoryResourceDescriptor gitRd = new GitRepositoryResourceDescriptor()\ndef Statement statement = new Statement()\ndef Envelope envelope = new Envelope()\n\npipeline {\n    agent any\n    stages {\n        stage('init') {\n            steps {\n                script {\n                    // Instantiate a SLSA Provenance\n                    provenance.construct()\n                    \n                    def String path = ''\n                    dir(\"/var/jenkins_home/workspace/${env.JOB_BASE_NAME}@libs\") {\n                        path = sh(\n                            script: 'find . -type d -name .git -maxdepth 2 -print -quit',\n                            returnStdout: true\n                        ).trim().replace('./', '').replace('/.git', '')\n                    }\n                    dir(\"/var/jenkins_home/workspace/${env.JOB_BASE_NAME}@libs/${path}\") {\n                        // Initialize a ResourceDescriptor for a git repository\n                        gitRd.construct()\n                        // Set the name of the ResourceDescriptor \n                        gitRd.setName('pipeline-library')\n                    }\n                }\n                script {\n                    sh 'touch test.json'\n                    sh 'echo \"{}\" \u003e test.json'\n                    \n                    // Create a ResourceDescriptor for file test.json\n                    fileRd.file('test.json')\n                }\n            }\n        }\n    }\n    post {\n        always {\n            script {\n                // Add git ResourceDescriptor as a builder dependency\n                provenance.addBuilderDependency(gitRd.get())\n                // Mark build as finished. (this step adds finishedAt Timestmap)\n                provenance.finish()\n                // Write to a file\n                provenance.write()\n                \n                // Create an In-Toto Statement\n                statement.construct()\n                // Add SLSA provenance to InToto attestation\n                statement.addProvenance(provenance.get())\n                // Add subject (ResourceDescriptor) to InToto attestation\n                statement.addSubject(fileRd.get())\n                // Save to a file\n                statement.write()\n\n                // Create a DSSEv1 envelope\n                envelope.construct()\n                // Add in-toto statement to the envelope\n                envelope.addInTotoStatement(statement)\n                // Save to a file\n                envelope.write()\n                \n                archiveArtifacts artifacts: '*.json', fingerprint: true, followSymlinks: false\n            }\n        }\n        cleanup {\n            cleanWs()\n        }\n    }\n}\n```\n\n## Artifacts\n\nHere you have the samples of artifacts it can be produced during the build.\n\n### SLSA Provenance\n\nExample of SLSA Provenance produced.\n\n```json\n{\n  \"buildDefinition\": {\n    \"buildType\": \"https://www.jenkins.io/Pipeline\",\n    \"externalParameters\": {},\n    \"internalParameters\": {\n      \"BRANCH\": \"*/master\",\n      \"ENVIRONMENT\": \"DEV\"\n    },\n    \"resolvedDependencies\": [\n      {\n        \"name\": \"pipeline-library\",\n        \"digest\": {\n          \"gitCommit\": {\n            \"gitCommit\": \"ccff45a82df61ab4efe41bf20a9bd22f8db1706c\"\n          }\n        },\n        \"uri\": \"git@github.com:angelcamposm/jenkins-shared-library.git\"\n      }\n    ]\n  },\n  \"runDetails\": {\n    \"builder\": {\n      \"id\": \"http://localhost:8080/job/test/103/\",\n      \"builderDependencies\": [],\n      \"version\": \"\"\n    },\n    \"metadata\": {\n      \"invocationId\": \"#103\",\n      \"startedOn\": \"2023-08-17T13:24:27Z\",\n      \"finishedOn\": \"2023-08-17T13:24:34Z\"\n    },\n    \"byproducts\": []\n  }\n}\n```\n\n### in-toto attestation\n\nExample of in-toto Statement (attestation) produced.\n\n```json\n{\n  \"_type\": \"https://in-toto.io/Statement/v1\",\n  \"subject\": [\n    {\n      \"name\": \"test.json\",\n      \"digest\": {\n        \"md5\": \"8a80554c91d9fca8acb82f023de02f11\",\n        \"sha1\": \"5f36b2ea290645ee34d943220a14b54ee5ea5be5\",\n        \"sha256\": \"ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356\",\n        \"sha512\": \"ca4b6defb8adcc010050bc8b1bb8f8092c4928b8a0fba32146abcfb256e4d91672f88ca2cdf6210e754e5b8ac5e23fb023806ccd749ac8b701f79a691f03c87a\"\n      },\n      \"annotations\": {\n        \"size\": 3,\n        \"createdAt\": \"2023-08-17T12:14:57Z\"\n      }\n    }\n  ],\n  \"predicateType\": \"https://slsa.dev/provenance/v1\",\n  \"predicate\": {\n    \"buildDefinition\": {\n      \"buildType\": \"https://www.jenkins.io/Pipeline\",\n      \"externalParameters\": {},\n      \"internalParameters\": {\n        \"BRANCH\": \"*/master\",\n        \"ENVIRONMENT\": \"DEV\"\n      },\n      \"resolvedDependencies\": [\n        {\n          \"name\": \"pipeline-library\",\n          \"digest\": {\n            \"gitCommit\": {\n              \"gitCommit\": \"9750e594fc52252416b84e225b29791286f9cdbd\"\n            }\n          },\n          \"uri\": \"git@github.com:angelcamposm/jenkins-shared-library.git\"\n        }\n      ]\n    },\n    \"runDetails\": {\n      \"builder\": {\n        \"id\": \"http://localhost:8080/job/test/100/\",\n        \"builderDependencies\": [],\n        \"version\": \"\"\n      },\n      \"metadata\": {\n        \"invocationId\": \"#100\",\n        \"startedOn\": \"2023-08-17T12:14:52Z\",\n        \"finishedOn\": \"2023-08-17T12:14:59Z\"\n      },\n      \"byproducts\": []\n    }\n  }\n}\n```\n\n### SSL DSSEv1\n\nExample of DSSEv1 envelope produced.\n\n```json\n{\n    \"payload\": \"eyJfdHlwZSI6Imh0dHBzOi8vaW4tdG90by5pby9TdGF0ZW1lbnQvdjEiLCJzdWJqZWN0IjpbeyJuYW1lIjoidGVzdC5qc29uIiwiZGlnZXN0Ijp7Im1kNSI6IjhhODA1NTRjOTFkOWZjYThhY2I4MmYwMjNkZTAyZjExIiwic2hhMSI6IjVmMzZiMmVhMjkwNjQ1ZWUzNGQ5NDMyMjBhMTRiNTRlZTVlYTViZTUiLCJzaGEyNTYiOiJjYTNkMTYzYmFiMDU1MzgxODI3MjI2MTQwNTY4ZjNiZWY3ZWFhYzE4N2NlYmQ3Njg3OGUwYjYzZTllNDQyMzU2Iiwic2hhNTEyIjoiY2E0YjZkZWZiOGFkY2MwMTAwNTBiYzhiMWJiOGY4MDkyYzQ5MjhiOGEwZmJhMzIxNDZhYmNmYjI1NmU0ZDkxNjcyZjg4Y2EyY2RmNjIxMGU3NTRlNWI4YWM1ZTIzZmIwMjM4MDZjY2Q3NDlhYzhiNzAxZjc5YTY5MWYwM2M4N2EifSwiYW5ub3RhdGlvbnMiOnsic2l6ZSI6MywiY3JlYXRlZEF0IjoiMjAyMy0wOC0xN1QxMzo5OjMyWiJ9fV0sInByZWRpY2F0ZVR5cGUiOiJodHRwczovL3Nsc2EuZGV2L3Byb3ZlbmFuY2UvdjEiLCJwcmVkaWNhdGUiOnsiYnVpbGREZWZpbml0aW9uIjp7ImJ1aWxkVHlwZSI6Imh0dHBzOi8vd3d3LmplbmtpbnMuaW8vUGlwZWxpbmUiLCJleHRlcm5hbFBhcmFtZXRlcnMiOnt9LCJpbnRlcm5hbFBhcmFtZXRlcnMiOnsiQlJBTkNIIjoiKi9tYXN0ZXIiLCJFTlZJUk9OTUVOVCI6IkRFViJ9LCJyZXNvbHZlZERlcGVuZGVuY2llcyI6W3sibmFtZSI6InBpcGVsaW5lLWxpYnJhcnkiLCJkaWdlc3QiOnsiZ2l0Q29tbWl0Ijp7ImdpdENvbW1pdCI6IjMzYWIxMWJjMjNmMmRkZDgzNTgyNzQ0NWM1ZmRmYWUzNjIxNTBkODAifX0sInVyaSI6ImdpdEBnaXRodWIuY29tOmFuZ2VsY2FtcG9zbS9qZW5raW5zLXNoYXJlZC1saWJyYXJ5LmdpdCJ9XX0sInJ1bkRldGFpbHMiOnsiYnVpbGRlciI6eyJpZCI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9qb2IvdGVzdC8xMDIvIiwiYnVpbGRlckRlcGVuZGVuY2llcyI6W10sInZlcnNpb24iOiIifSwibWV0YWRhdGEiOnsiaW52b2NhdGlvbklkIjoiIzEwMiIsInN0YXJ0ZWRPbiI6IjIwMjMtMDgtMTdUMTM6OToyN1oiLCJmaW5pc2hlZE9uIjoiMjAyMy0wOC0xN1QxMzo5OjM0WiJ9LCJieXByb2R1Y3RzIjpbXX19fQ==\",\n    \"payloadType\": \"application/vnd.in-toto+json\",\n    \"signatures\": []\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelcamposm%2Fjenkins-shared-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangelcamposm%2Fjenkins-shared-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelcamposm%2Fjenkins-shared-library/lists"}