Skip to content

Commit 9157815

Browse files
committed
Fix write policy for Nexus SNAPSHOT repositories
1 parent 91a6f67 commit 9157815

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

nexus/createNexusRepos.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ nexus_curl() {
6262
fi
6363

6464
if [[ "${response}" == *"errors"* ]]; then
65-
error_msg=$(echo "${response}" | jq -M '."errors"[0].msg')
65+
error_msg=$(echo "${response}" | jq -M '."errors"[0].msg')
6666
echo "ERROR: ${error_msg}" >&2
6767
exit 1
6868
fi
@@ -75,8 +75,12 @@ nexus_curl() {
7575
createRepo () {
7676
local repo_id="${1:-}"
7777
local repo_policy="${2:-}"
78+
local write_policy="ALLOW_WRITE_ONCE"
79+
if [[ "${repo_policy}" == "SNAPSHOT" ]]; then
80+
write_policy="ALLOW_WRITE"
81+
fi
7882
echo "Creating Nexus repo '${repo_id}'..."
79-
local json="{\"data\":{\"repoType\": \"hosted\", \"id\": \"${repo_id}\", \"name\": \"${repo_id}\", \"writePolicy\": \"ALLOW_WRITE_ONCE\", \"browseable\": true, \"indexable\": true, \"exposed\": true, \"notFoundCacheTTL\": 1440, \"repoPolicy\": \"${repo_policy}\", \"provider\": \"maven2\", \"providerRole\": \"org.sonatype.nexus.proxy.repository.Repository\", \"downloadRemoteIndexes\": false, \"checksumPolicy\": \"IGNORE\" }}"
83+
local json="{\"data\":{\"repoType\": \"hosted\", \"id\": \"${repo_id}\", \"name\": \"${repo_id}\", \"writePolicy\": \"${write_policy}\", \"browseable\": true, \"indexable\": true, \"exposed\": true, \"notFoundCacheTTL\": 1440, \"repoPolicy\": \"${repo_policy}\", \"provider\": \"maven2\", \"providerRole\": \"org.sonatype.nexus.proxy.repository.Repository\", \"downloadRemoteIndexes\": false, \"checksumPolicy\": \"IGNORE\" }}"
8084
nexus_curl "${json}" "${rest_api_base_url}/repositories" "POST"
8185
}
8286

@@ -94,7 +98,7 @@ addRepoToGroupRepo() {
9498
local group_id="${2:-}"
9599
echo "Adding repo '${repo_id}' to group repo '${group_id}'..."
96100

97-
# get existing repos
101+
# get existing repos
98102
json_old=$(nexus_curl "" "${rest_api_base_url}/repo_groups/${group_id}" "GET")
99103
# add new repo
100104
json=$(echo "${json_old}" | jq ".data.repositories += [{\"id\": \"${repo_id}\", \"name\": \"${repo_id}\", \"resourceURI\": \"https://repo.eclipse.org/service/local/repo_groups/releases/${repo_id}\"}]")

0 commit comments

Comments
 (0)