{"id":14984798,"url":"https://github.com/releaseworks/jenkinslib","last_synced_at":"2025-09-04T05:08:24.883Z","repository":{"id":175663896,"uuid":"174353403","full_name":"releaseworks/jenkinslib","owner":"releaseworks","description":"Easy-to-use helper functions for Jenkinsfiles","archived":false,"fork":false,"pushed_at":"2019-11-12T10:45:55.000Z","size":14,"stargazers_count":20,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-04T05:08:15.648Z","etag":null,"topics":["ci","continuous-delivery","jenkins","jenkins-pipeline","jenkinsfile"],"latest_commit_sha":null,"homepage":"https://release.works","language":"Groovy","has_issues":true,"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/releaseworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-03-07T13:55:13.000Z","updated_at":"2023-08-24T17:34:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"2c4a5cb4-bc9d-4661-a673-5ba933136649","html_url":"https://github.com/releaseworks/jenkinslib","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"e456616151810061e3e805ba143969cd0ab5e036"},"previous_names":["releaseworks/jenkinslib"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/releaseworks/jenkinslib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/releaseworks%2Fjenkinslib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/releaseworks%2Fjenkinslib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/releaseworks%2Fjenkinslib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/releaseworks%2Fjenkinslib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/releaseworks","download_url":"https://codeload.github.com/releaseworks/jenkinslib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/releaseworks%2Fjenkinslib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273555460,"owners_count":25126316,"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-09-04T02:00:08.968Z","response_time":61,"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":["ci","continuous-delivery","jenkins","jenkins-pipeline","jenkinsfile"],"created_at":"2024-09-24T14:09:41.148Z","updated_at":"2025-09-04T05:08:24.851Z","avatar_url":"https://github.com/releaseworks.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jenkins Libraries\nThis repository includes helper functions for making life easier with Jenkins and Jenkinsfiles.\n\n## Usage\nPlace this at the top of your Jenkinsfile:\n```\n@Library('github.com/releaseworks/jenkinslib') _\n```\n_(Note the trailing underscore!)_\n\n## Function Reference\nAvailable functions:\n* [SlackMessage](#slackmessage)\n* [Terraform](#terraform)\n* [AWS](#slackmessage)\n* [withElasticContainerRegistry](#withelasticcontainerregistry)\n\n### SlackMessage\nThis function posts a message to a Slack channel from a Jenkinsfile using a Slack Incoming Webhook. Create a Slack incoming webhook with these instructions: https://get.slack.help/hc/en-gb/articles/115005265063-Incoming-webhooks-for-Slack\n\nUsage:\n```\nSlackMessage(webhookUrl: 'https://hooks.slack.com/XXXX',\n             channel: '',\n             color: 'good',\n             username: 'Jenkins',\n             message: '')\n```\n\nExample:\n```\nSlackMessage(webhookUrl: \"https://hooks.slack.com/XXXX\",\n             channel: \"#ci\",\n             message: \"Build succeeded!\")\n```\n\nReplace the webhookUrl value with your unique webhook URL.\n\nAn advanced example for catching errors with a try-catch block:\n```\ntry {\n    def url = 'https://hooks.slack.com/XXXX'\n\n    stage('Build app') {\n        // your build steps here\n    }\n\n    stage('Post notification') {\n        SlackMessage(webhookUrl: url,\n                     channel: \"#ci\",\n                     message: \"Build succeeded for ${env.JOB_NAME}!\")\n    }\n\n} catch(error) {\n    SlackMessage(webhookUrl: url,\n                 channel: \"#ci\",\n                 message: \"Build failed: $error - \u003c${env.BUILD_URL}|view logs\u003e\")\n    throw error\n}\n```\n\n### Terraform\nRun Terraform commands in a Jenkinsfile. See https://terraform.io\n\nThis command requires the Docker Pipeline plugin and a working Docker server.\n\nUsage:\n```\nTerraform(command, version)\n```\n\nThe version defaults to the latest version.\n\nThe following environment variables, if set, are passed to Terraform: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`, `TF_INPUT`, `TF_LOG`, `TF_LOG_PATH`, `TF_CLI_ARGS`.\n\nExample:\n```\nTerraform(\"plan\")\nTerraform(\"apply -var-file=environment.tfvars\")\nTerraform(\"validate\", \"0.11.11\")\n```\n\n### AWS\nRun AWS CLI commands in a Jenkinsfile.\n\nThis command requires the Docker Pipeline plugin and a working Docker server.\n\nUsage:\n```\nAWS(command)\n```\n\nThe following environment variables, if set, are passed to AWS CLI: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`.\n\nExample:\n```\nwithEnv([\"AWS_ACCESS_KEY_ID=abc\", \"AWS_SECRET_ACCESS_KEY=def\", \"AWS_DEFAULT_REGION=eu-west-1\"]) {\n    AWS(\"ec2 describe-instances\")\n}\n\nAWS(\"s3 ls\")\n```\n\nNote: Adding AWS API credentials into your pipeline code is not recommended. Use Jenkins Credentials (and a `withCredentials() { .. }` block), or IAM Roles.\n\n### withElasticContainerRegistry\nRun build steps when authenticated to an AWS Elastic Container Registry (ECR).\n\nThis command requires the Docker Pipeline plugin and a working Docker server.\n\nUsage:\n```\nwithElasticContainerRegistry {\n    // build steps here\n}\n```\n\nThe following environment variables, if set, are passed to AWS CLI for authentication: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`.\n\nExample:\n```\nwithEnv([\"AWS_ACCESS_KEY_ID=abc\", \"AWS_SECRET_ACCESS_KEY=def\", \"AWS_DEFAULT_REGION=eu-west-1\"]) {\n    withElasticContainerRegistry {\n        // Build image in the current working directory\n        def app = docker.build(\"ACCOUNT-ID.dkr.ecr.eu-west-1.amazonaws.com/app\")\n\n        // Push to ECR\n        app.push(\"${env.BUILD_NUMBER}\")\n    }\n}\n```\n\nNote: Adding AWS API credentials into your pipeline code is not recommended. Use Jenkins Credentials (and a `withCredentials() { .. }` block), or IAM Roles.\n\n## Contributing\nAll pull requests are very welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freleaseworks%2Fjenkinslib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freleaseworks%2Fjenkinslib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freleaseworks%2Fjenkinslib/lists"}