-
Notifications
You must be signed in to change notification settings - Fork 20
/
pipelines.yml
188 lines (183 loc) · 9.06 KB
/
pipelines.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# Update commit status in GitHub
updateCommitStatus: &UPDATE_COMMIT_STATUS
onStart:
- update_commit_status jfrog_cli_plugins_reg_git --context "$step_name"
onComplete:
- update_commit_status jfrog_cli_plugins_reg_git --context "$step_name"
commonConfiguration: &COMMON_CONFIGURATION
inputResources:
- name: jfrog_cli_plugins_reg_git
resources:
- name: buildJfrogCliPluginGit
type: GitRepo
configuration:
path: jfrog/jfrog-cli-plugins-reg
gitProvider: il_automation
buildOn:
# Manually trigger only
commit: false
branches:
# Only build on the master
include: master
files:
include: ^plugins\/.+
- name: jfrog_cli_plugins_reg_git
type: GitRepo
configuration:
path: jfrog/jfrog-cli-plugins-reg
gitProvider: il_automation
buildOn:
commit: false
pullRequestCreate: true
branches:
include: master
files:
include: ^plugins\/.+
- name: jfrog_cli_core_trigger
type: GitRepo
configuration:
path: jfrog/jfrog-cli-core
gitProvider: il_automation
buildOn:
commit: false
releaseCreate: true
branches:
include: master
pipelines:
- name: build_jfrog_cli_plugin
steps:
- name: BuildAndPush
type: Bash
configuration:
integrations:
- name: releases_jfrog_io_deployer
- name: ecosys_entplus_deployer
inputResources:
- name: buildJfrogCliPluginGit
runtime:
type: image
image:
custom:
name: releases-docker.jfrog.io/jfrog-ecosystem-integration-env
tag: 1.11.5
environmentVariables:
JFROG_CLI_PLUGIN_DESCRIPTOR_FILE_NAME: "file-name-with-extension.yml"
execution:
onStart:
- update_commit_status buildJfrogCliPluginGit --context "$step_name"
onExecute:
# Install yq to parse yaml.
- GO111MODULE=on go install github.com/mikefarah/yq/[email protected]
# Extract params from yaml.
- ymlPath="$res_buildJfrogCliPluginGit_resourcePath/plugins/$JFROG_CLI_PLUGIN_DESCRIPTOR_FILE_NAME"
- echo "extracting details from $ymlPath"
- JFROG_CLI_PLUGIN_PLUGIN_NAME=$(~/go/bin/yq e ".pluginName" $ymlPath) && echo $JFROG_CLI_PLUGIN_PLUGIN_NAME
- JFROG_CLI_PLUGIN_VERSION=$(~/go/bin/yq e ".version" $ymlPath) && echo $JFROG_CLI_PLUGIN_VERSION
- pluginRepoFullUrl=$(~/go/bin/yq e ".repository" $ymlPath) && echo $pluginRepoFullUrl
- pluginRepoName=$(basename $pluginRepoFullUrl .git) && echo $pluginRepoName
- pluginRelativePath=$(~/go/bin/yq e ".relativePath // \"\"" $ymlPath) && echo $pluginRelativePath
# Clone plugin repo.
- git clone $pluginRepoFullUrl
# Copy the plugin distribution spec from the registry repo to the plugin repo.
- cp "$res_buildJfrogCliPluginGit_resourcePath/pipelinesScripts/specs/plugin-rbc-spec.json" "./$pluginRepoName/$pluginRelativePath"
- cd "./$pluginRepoName/$pluginRelativePath"
# Install JFrog CLI
- curl -fL https://install-cli.jfrog.io | sh
- jf c add internal --url=$int_ecosys_entplus_deployer_url --user=$int_ecosys_entplus_deployer_user --password=$int_ecosys_entplus_deployer_apikey
# Run plugin release script with the required env variables.
- >
env -i PATH=$PATH HOME=$HOME PWD=$PWD CI="true"
JFROG_CLI_PLUGINS_SERVER="internal"
JFROG_CLI_PLUGINS_REPO="ecosys-jfrog-cli-plugins"
JFROG_CLI_PLUGIN_PLUGIN_NAME=$JFROG_CLI_PLUGIN_PLUGIN_NAME
JFROG_CLI_PLUGIN_VERSION=$JFROG_CLI_PLUGIN_VERSION
jf plugin p "$JFROG_CLI_PLUGIN_PLUGIN_NAME" "$JFROG_CLI_PLUGIN_VERSION"
# Distribute Plugin to releases.
- options="--url=$int_ecosys_entplus_deployer_url/distribution --user=$int_ecosys_entplus_deployer_user --password=$int_ecosys_entplus_deployer_apikey"
- jf ds rbc "cli-plugins-$JFROG_CLI_PLUGIN_PLUGIN_NAME" $JFROG_CLI_PLUGIN_VERSION --spec="plugin-rbc-spec.json" --spec-vars="NAME=$JFROG_CLI_PLUGIN_PLUGIN_NAME;VERSION=$JFROG_CLI_PLUGIN_VERSION" --sign $options
- jf ds rbd "cli-plugins-$JFROG_CLI_PLUGIN_PLUGIN_NAME" $JFROG_CLI_PLUGIN_VERSION --site=releases.jfrog.io --sync $options
# Copy version to 'latest' directory in releases.jfrog.io
- jf rt cp "jfrog-cli-plugins/$JFROG_CLI_PLUGIN_PLUGIN_NAME/$JFROG_CLI_PLUGIN_VERSION/(*)" "jfrog-cli-plugins/$JFROG_CLI_PLUGIN_PLUGIN_NAME/latest/{1}" --url=https://releases.jfrog.io/artifactory/ --access-token=$int_releases_jfrog_io_deployer_access_token
onComplete:
- update_commit_status buildJfrogCliPluginGit --context "$step_name"
- name: upgrade_plugin_on_core_release
configuration:
runtime:
type: image
image:
custom:
name: releases-docker.jfrog.io/jfrog-ecosystem-integration-env
tag: 1.11.5
steps:
- name: upgrade_plugin_on_core_release
type: Bash
configuration:
inputResources:
- name: jfrog_cli_core_trigger
integrations:
- name: JFrog_CLI_Plugins_Updater
- name: JFrog_CLI_Plugins_Issuer
execution:
onExecute:
- git clone https://github.com/jfrog/jfrog-cli-plugins.git && jfrogCliPluginsPath=`pwd`/jfrog-cli-plugins
- git clone https://github.com/jfrog/jfrog-cli-plugins-reg.git && cd jfrog-cli-plugins-reg/pipelinesScripts/validator
- env -i PATH=$PATH GOPROXY=https://goproxy.io,direct issue_token=$int_JFrog_CLI_Plugins_Issuer_token HOME=$HOME PWD=$PWD JAVA_HOME=$JAVA_HOME GRADLE_HOME=$GRADLE_HOME MAVEN_HOME=$MAVEN_HOME go run validator.go upgradejfrogplugins $jfrogCliPluginsPath
- cd $jfrogCliPluginsPath
# Override origin.
- git remote set-url origin https://github.com/jfrog/jfrog-cli-plugins.git && git fetch origin main && git checkout main
# Check if new commits were added.
- "[[ $(git log origin/main...main --oneline | wc -l) -eq 0 ]]"
# Check if the staged files do not include .mod or .sum files.
- "[[ $(git diff --name-only --staged | grep -v -e .mod$ -e.sum$ | wc -l) -eq 0 ]]"
# Check total number of staged files is not greater than twice the number of directories (plugins).
- "[[ $(git diff --name-only --staged | wc -l) -lt $(($(ls -l | grep ^d | wc -l)*2+1)) ]]"
# Commit and push
- git config user.email "[email protected]"
- git config user.name "JFrog_CLI_Plugins_Updater"
- git commit -m "Updated plugins to the latest releases of jfrog-cli-core and jfrog-client-go"
- git push https://[email protected]/jfrog/jfrog-cli-plugins.git main
onFailure:
- "curl --location --request POST \"https://api.github.com/repos/jfrog/jfrog-cli-plugins-reg/issues\" --header \"Authorization: token $int_JFrog_CLI_Plugins_Issuer_token\" --header \"Content-Type: application/json\" --data-raw \"{\\\"title\\\":\\\"JFrog Pipelines $pipeline_name run number $run_number failed\\\"}\""
- name: plugin_validation
configuration:
runtime:
type: image
image:
custom:
name: releases-docker.jfrog.io/jfrog-ecosystem-integration-env
tag: 1.11.5
steps:
# Validate PR contains only the plugin descriptor
- name: PR_includes_only_plugin_descriptor
type: Bash
configuration:
<<: *COMMON_CONFIGURATION
execution:
<<: *UPDATE_COMMIT_STATUS
onExecute:
- cd $res_jfrog_cli_plugins_reg_git_resourcePath/pipelinesScripts/validator
- env -i PATH=$PATH HOME=$HOME PWD=$PWD JAVA_HOME=$JAVA_HOME GRADLE_HOME=$GRADLE_HOME MAVEN_HOME=$MAVEN_HOME go run validator.go extension
# Validate plugin descriptor yml
- name: Plugin_descriptor_structure_is_valid
type: Bash
configuration:
<<: *COMMON_CONFIGURATION
inputSteps:
- name: PR_includes_only_plugin_descriptor
execution:
<<: *UPDATE_COMMIT_STATUS
onExecute:
- cd $res_jfrog_cli_plugins_reg_git_resourcePath/pipelinesScripts/validator
- env -i PATH=$PATH HOME=$HOME PWD=$PWD JAVA_HOME=$JAVA_HOME GRADLE_HOME=$GRADLE_HOME MAVEN_HOME=$MAVEN_HOME go run validator.go structure
# Run `go vet ./...` and `go test ./...`
- name: Plugin_tests_passed
type: Bash
configuration:
<<: *COMMON_CONFIGURATION
inputSteps:
- name: Plugin_descriptor_structure_is_valid
execution:
<<: *UPDATE_COMMIT_STATUS
onExecute:
- cd $res_jfrog_cli_plugins_reg_git_resourcePath/pipelinesScripts/validator
- env -i PATH=$PATH HOME=$HOME PWD=$PWD JAVA_HOME=$JAVA_HOME GRADLE_HOME=$GRADLE_HOME MAVEN_HOME=$MAVEN_HOME go run validator.go tests