You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hooks/jenkins/jira-workflow/README.md
+172-5Lines changed: 172 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,12 @@ In order to configure our Jenkins instance to receive `webhooks` and process the
22
22
-[Credentials Binding](https://plugins.jenkins.io/credentials-binding): Allows credentials to be bound to environment variables for use from miscellaneous build steps.
23
23
-[Credentials](https://plugins.jenkins.io/credentials): This plugin allows you to store credentials in Jenkins.
24
24
25
-
### Getting Jenkins set up
25
+
### Setting up the repo
26
+
27
+
This example pipeline will read the workflow settings from a YAML file in the `.github` directory of the repository where the pipeline lives, _not_ the repository where the code for your project lives. This particular example is a standalone Jenkins pipeline that will be triggered by multiple projects/orgs.
Before getting started with the pipeline you'll need to setup a few things.
54
+
55
+
1. Create a `username`/`password` credential which uses your GitHub token
56
+
2. Create a `username`/`password` credential which has access to Jira
57
+
3. Create a Jira configuration in `Settings`
58
+
59
+
60
+
This demonstration will make use of the [Declarative Pipeline](https://jenkins.io/doc/book/pipeline/syntax) syntax for Jenkins, and not the less structured _advanced scripting_ syntax. So, in getting started we'll note a few things.
61
+
62
+
First, because we're dynamically generating parallel steps, we'll need to declare our variables _outside_ the pipeline so we don't hit errors when assigning values to them.
63
+
64
+
```groovy
65
+
def settings
66
+
def projectInfo
67
+
def githubUrl = "https://api.github.com/"
68
+
// This is an array we'll use for dynamic parallization
69
+
def repos = [:]
70
+
```
71
+
72
+
Once you've declared them, some with values you won't change and some with no values (we'll set them dynamically), let's enable some debug output so we can test our pipeline and adjust it for the things we need. **This step is optional, but will help you extend this example.**
73
+
74
+
```groovy
75
+
node {
76
+
echo sh(returnStdout: true, script: 'env')
77
+
}
78
+
```
79
+
80
+
Now we can begin the pipeline itself
81
+
82
+
```groovy
83
+
pipeline {
84
+
```
85
+
86
+
#### Setting up the triggers
87
+
The *Generic Webhook Trigger* plugin makes use of a token to differentiate pipelines. You can generate a generic token for this pipeline by running `uuidgen` at the command line on a Unix system, or `[Guid]::NewGuid().ToString()` in PowerShell.
Once you have generated your unique ID, add the token to the pipeline as a trigger. We'll capture a few variables about the webhook we'll receive as well, and use them later in the pipeline
Once we've read the settings file (or aborted because one doesn't exist), we'll lookup the project info from Jira. The webhook will send us a Project ID, which won't really help us as humans to map, so we'll look this up once we get the payload.
0 commit comments