Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Azure Build Policy Apply
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Azure Build Policy Apply
Commits
e4d25f6f
There was an error fetching the commit references. Please try again later.
Commit
e4d25f6f
authored
1 year ago
by
Recolic
🏡
Browse files
Options
Downloads
Patches
Plain Diff
.try:use org url, use new json
parent
1dc24f61
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+11
-3
11 additions, 3 deletions
README.md
apply.sh
+64
-37
64 additions, 37 deletions
apply.sh
with
75 additions
and
40 deletions
README.md
+
11
−
3
View file @
e4d25f6f
...
@@ -9,12 +9,20 @@
...
@@ -9,12 +9,20 @@
Should work on all POSIX-compatible systems (
`#!/usr/bin/env`
)
Should work on all POSIX-compatible systems (
`#!/usr/bin/env`
)
## sample
## use sample
recolic.net test
```
# pat=z42dimrcfgylmvnu7cyzwnzqseom2obwvwaypmtm5id4tigqucmq ./apply.sh --org-url https://dev.azure.com/azvse --proj-name aztest --repo-id a4822210-511f-427f-a36d-26a14c29cc89 --branch bensl/tmpbuild/114514 --build-definition-id 2
```
MS PROD
```
```
# pat=z42dimrcfgylmvnu7cyzwnzqseom2obwvwaypmtm5id4tigqucmq ./apply.sh --org-name azvse
--proj-name
aztest
--repo-
id a4822210-511f-427f-a36d-26a14c29cc89 --branch bensl/tmpbuild/114514 --build-definition-id 2
./apply.sh --org-url https://msazure.visualstudio.com
--proj-name
One
--repo-
name Networking-Datapath-HostSdnStack-SMAgent --branch bensl/tmpbuild/1207.1 --pipeline-name Overlake-Build-PullRequest
./apply.sh --org-name msazure --proj-name One --repo-name Networking-Datapath-HostSdnStack-SMAgent --branch bensl/tmpbuild/1207.1 --pipeline-name Overlake-Build-PullRequest
repo_id: 12e0c399-4e80-42b6-aff2-dc693505d5f7
repo_id: 12e0c399-4e80-42b6-aff2-dc693505d5f7
build_definition_id: 270313
build_definition_id: 270313
```
```
...
...
This diff is collapsed.
Click to expand it.
apply.sh
+
64
−
37
View file @
e4d25f6f
...
@@ -3,20 +3,20 @@
...
@@ -3,20 +3,20 @@
show_usage
()
{
show_usage
()
{
cat
<<-
EOF
cat
<<-
EOF
Usage:
Usage:
$0
--org-
name
{string} --proj-name {string} [--repo-name {string} | --repo-id {string}] [--branch {string}] [--pipeline-name {string} | --build-definition-id {number}]
$0
--org-
url
{string} --proj-name {string} [--repo-name {string} | --repo-id {string}] [--branch {string}] [--pipeline-name {string} | --build-definition-id {number}]
Examples:
Examples:
$0
--org-
name
azvse --proj-name aztest --repo-name aztest --branch bensl/tmpbuild/1201 --pipeline-name Overlake-Build-PullRequest
$0
--org-
url
azvse --proj-name aztest --repo-name aztest --branch bensl/tmpbuild/1201 --pipeline-name Overlake-Build-PullRequest
$0
--org-
name
azvse --proj-name aztest --repo-id a4822210-511f-427f-a36d-26a14c29cc89 --branch bensl/tmpbuild/1201 --build-definition-id 2
$0
--org-
url
azvse --proj-name aztest --repo-id a4822210-511f-427f-a36d-26a14c29cc89 --branch bensl/tmpbuild/1201 --build-definition-id 2
EOF
EOF
}
}
get_proj_id
()
{
get_proj_id
()
{
az devops project show
\
az devops project show
\
--project
One
\
--project
"
$proj_name
"
\
--query
"id"
\
--query
"id"
\
--org
https://msazure.visualstudio.com/
\
--org
"
$org_url
"
\
--output
tsv
--output
tsv
}
}
typeset
-fx
get_proj_id
typeset
-fx
get_proj_id
...
@@ -43,8 +43,8 @@ typeset -fx get_build_definition_id
...
@@ -43,8 +43,8 @@ typeset -fx get_build_definition_id
while
[[
$#
-gt
0
]]
;
do
while
[[
$#
-gt
0
]]
;
do
case
"
$1
"
in
case
"
$1
"
in
--org-
name
)
--org-
url
)
org_
name
=
$2
org_
url
=
$2
shift
2
shift
2
;;
;;
--proj-name
)
--proj-name
)
...
@@ -82,9 +82,11 @@ while [[ $# -gt 0 ]]; do
...
@@ -82,9 +82,11 @@ while [[ $# -gt 0 ]]; do
esac
esac
done
done
org_url
=
https://msazure.visualstudio.com/
############### Harcode! change me!
# user_email="tmp1@recolic.net"
user_email
=
"bensl@microsoft.com"
if
[[
!
${
org_
name
}
||
!
${
proj_name
}
||
(!
${
repo_name
}
&&
!
${
repo_id
}
)
||
(!
${
pipeline_name
}
&&
!
${
build_definition_id
}
)
]]
;
then
if
[[
!
${
org_
url
}
||
!
${
proj_name
}
||
(!
${
repo_name
}
&&
!
${
repo_id
}
)
||
(!
${
pipeline_name
}
&&
!
${
build_definition_id
}
)
]]
;
then
show_usage
show_usage
exit
1
exit
1
fi
fi
...
@@ -117,7 +119,6 @@ print_policy_list() {
...
@@ -117,7 +119,6 @@ print_policy_list() {
--project
"
${
proj_name
}
"
--project
"
${
proj_name
}
"
}
}
user_email
=
"bensl@microsoft.com"
setup_branch_security
()
{
setup_branch_security
()
{
GIT_REPO_NAMESPACE
=
2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87
GIT_REPO_NAMESPACE
=
2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87
az devops security permission update
\
az devops security permission update
\
...
@@ -132,31 +133,57 @@ setup_build_policy() {
...
@@ -132,31 +133,57 @@ setup_build_policy() {
curl
-X
POST
"
${
org_url
}
/
${
proj_name
}
/_apis/policy/configurations?api-version=7.2-preview.1"
\
curl
-X
POST
"
${
org_url
}
/
${
proj_name
}
/_apis/policy/configurations?api-version=7.2-preview.1"
\
-H
"Authorization: Basic
$(
echo
-n
:
${
pat
}
|
base64
)
"
\
-H
"Authorization: Basic
$(
echo
-n
:
${
pat
}
|
base64
)
"
\
-H
'Content-Type: application/json'
\
-H
'Content-Type: application/json'
\
-d
'
-d
'{
{
"type": {
"isEnabled": true,
"id": "fa4e907d-c16b-4a4c-9dfa-4906e5d171dd"
"isBlocking": true,
},
"type": {
"revision": 1,
"id": "fa4e907d-c16b-4a4c-9dfa-4906e5d171dd"
"isDeleted": false,
},
"isBlocking": true,
"settings": {
"isEnabled": true,
"allowDownvotes": false,
"settings": {
"blockLastPusherVote": true,
"allowDownvotes": false,
"creatorVoteCounts": false,
"blockLastPusherVote": true,
"minimumApproverCount": 2,
"creatorVoteCounts": false,
"requireVoteOnEachIteration": true,
"requireVoteOnLastIteration": true,
"requireVoteOnLastIteration": true,
"resetOnSourcePush": false,
"resetOnSourcePush": false,
"resetRejectionsOnSourcePush": false,
"resetRejectionsOnSourcePush": false,
"requireVoteOnEachIteration": true,
"scope": [
"minimumApproverCount": 2,
{
"scope": [
"repositoryId": "'
${
repo_id
}
'",
{
"refName": "refs/heads/'
${
branch
}
'",
"repositoryId": "'
${
repo_id
}
'",
"matchKind": "exact"
"refName": "refs/heads/'
${
branch
}
'",
}
"matchKind": "Exact"
]
}
}
]
}'
}
}'
# '
# {
# "isEnabled": true,
# "isBlocking": true,
# "type": {
# "id": "fa4e907d-c16b-4a4c-9dfa-4906e5d171dd"
# },
# "settings": {
# "allowDownvotes": false,
# "blockLastPusherVote": true,
# "creatorVoteCounts": false,
# "minimumApproverCount": 2,
# "requireVoteOnEachIteration": true,
# "requireVoteOnLastIteration": true,
# "resetOnSourcePush": false,
# "resetRejectionsOnSourcePush": false,
# "scope": [
# {
# "repositoryId": "'${repo_id}'",
# "refName": "refs/heads/'${branch}'",
# "matchKind": "exact"
# }
# ]
# }
# }'
}
}
setup_build_validation
()
{
setup_build_validation
()
{
...
@@ -175,6 +202,6 @@ setup_build_validation() {
...
@@ -175,6 +202,6 @@ setup_build_validation() {
}
}
print_policy_list
print_policy_list
setup_branch_security
#
setup_branch_security
setup_build_policy
setup_build_policy
setup_build_validation
#
setup_build_validation
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment