forked from manishas-jfrog/jfrog-pipelines-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjfrog-pipelines-hello-world2.yml
82 lines (76 loc) · 3.28 KB
/
jfrog-pipelines-hello-world2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
resources:
- name: myFirstRepo
type: GitRepo
configuration:
# SCM integration where the repository is located
# gitProvider: {{ Values.myRepo.gitProvider }}
# Repository path, including org name/repo name
# path: {{ Values.myRepo.path }} #manishas-jfrog/jfrog-pipelines-hello-world # replace with your repository name
gitProvider: zen1 # replace with your integration
path: aaragorn2/jfrog-pipelines-hello-world # replace with your repository name
branches:
# Specifies which branches will trigger dependent steps
include: master
- name: myPropertyBag
type: PropertyBag
configuration:
commitSha: 1
runID: 1
pipelines:
- name: my_first_pipeline
steps:
- name: p1_s1
type: Bash
configuration:
inputResources:
# Sets up step to be triggered when there are commit events to myFirstRepo
- name: myFirstRepo
execution:
onExecute:
# Data from input resources is available as env variables in the step
- echo $res_myFirstRepo_commitSha
# The next two commands add variables to run state, which is available to all downstream steps in this run
# Run state documentation: https://www.jfrog.com/confluence/display/JFROG/Creating+Stateful+Pipelines#CreatingStatefulPipelines-RunState
- add_run_variables current_runid=$run_id
- add_run_variables commitSha=$res_myFirstRepo_commitSha
# This variable is written to pipeline state in p1_s3.
# So this will be empty during first run and will be set to prior run number in subsequent runs
# Pipeline state documentation: https://www.jfrog.com/confluence/display/JFROG/Creating+Stateful+Pipelines#CreatingStatefulPipelines-PipelineState
- echo "Previous run ID is $prev_runid"
- name: p1_s2
type: Bash
configuration:
inputSteps:
- name: p1_s1
execution:
onExecute:
# Demonstrates the availability of an env variable written to run state during p1_s1
- echo $current_runid
- name: p1_s3
type: Bash
configuration:
inputSteps:
- name: p1_s2
outputResources:
- name: myPropertyBag
execution:
onExecute:
- echo $current_runid
# Writes current run number to pipeline state
- add_pipeline_variables prev_runid=$run_id
# Uses an utility function to update the output resource with the commitSha that triggered this run
# Dependent pipelines can be configured to trigger when this resource is updated
# Utility functions documentation: https://www.jfrog.com/confluence/display/JFROG/Pipelines+Utility+Functions
- write_output myPropertyBag commitSha=$commitSha runID=$current_runid
- name: my_second_pipeline
steps:
- name: p2_s1
type: Bash
configuration:
inputResources:
# Sets up step to be triggered when myPropertyBag is updated
- name: myPropertyBag
execution:
onExecute:
# Retrieves the commitSha from input resource
- echo "CommitSha is $res_myPropertyBag_commitSha"