use the nexus https endpoint
This commit is contained in:
parent
f6ab32d029
commit
40a0bfcf78
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
nexus_domain=$(hostname --fqdn)
|
||||||
|
|
||||||
. /vagrant/provision/nexus-groovy.sh
|
. /vagrant/provision/nexus-groovy.sh
|
||||||
|
|
||||||
# run the provision script.
|
# run the provision script.
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
nexus_domain=$(hostname --fqdn)
|
||||||
|
|
||||||
. /vagrant/provision/nexus-groovy.sh
|
. /vagrant/provision/nexus-groovy.sh
|
||||||
|
|
||||||
# list existing scripts.
|
# list existing scripts.
|
||||||
#http -a "$admin_username:$admin_password" http://localhost:8081/service/siesta/rest/v1/script | jq .
|
#http -a "$admin_username:$admin_password" https://$nexus_domain/service/siesta/rest/v1/script | jq .
|
||||||
|
|
||||||
# run the provision script.
|
# run the provision script.
|
||||||
response=$(nexus-groovy provision)
|
response=$(nexus-groovy provision)
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ function nexus-groovy {
|
||||||
local delete_result=$(http \
|
local delete_result=$(http \
|
||||||
-a "$admin_username:$admin_password" \
|
-a "$admin_username:$admin_password" \
|
||||||
--ignore-stdin \
|
--ignore-stdin \
|
||||||
DELETE http://localhost:8081/service/siesta/rest/v1/script/provision.groovy)
|
DELETE https://$nexus_domain/service/siesta/rest/v1/script/provision.groovy)
|
||||||
|
|
||||||
local create_result=$(http \
|
local create_result=$(http \
|
||||||
-a "$admin_username:$admin_password" \
|
-a "$admin_username:$admin_password" \
|
||||||
--ignore-stdin \
|
--ignore-stdin \
|
||||||
--check-status \
|
--check-status \
|
||||||
POST http://localhost:8081/service/siesta/rest/v1/script \
|
POST https://$nexus_domain/service/siesta/rest/v1/script \
|
||||||
name=provision.groovy \
|
name=provision.groovy \
|
||||||
type=groovy \
|
type=groovy \
|
||||||
"content=@$source_filename")
|
"content=@$source_filename")
|
||||||
|
|
@ -27,6 +27,6 @@ function nexus-groovy {
|
||||||
-a "$admin_username:$admin_password" \
|
-a "$admin_username:$admin_password" \
|
||||||
--ignore-stdin \
|
--ignore-stdin \
|
||||||
--check-status \
|
--check-status \
|
||||||
POST http://localhost:8081/service/siesta/rest/v1/script/provision.groovy/run \
|
POST https://$nexus_domain/service/siesta/rest/v1/script/provision.groovy/run \
|
||||||
Content-Type:text/plain
|
Content-Type:text/plain
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,9 @@ openssl x509 \
|
||||||
# copy the certificate to a place where it can be used by other machines.
|
# copy the certificate to a place where it can be used by other machines.
|
||||||
mkdir -p /vagrant/shared
|
mkdir -p /vagrant/shared
|
||||||
cp $config_fqdn-crt.* /vagrant/shared
|
cp $config_fqdn-crt.* /vagrant/shared
|
||||||
|
# configure our system to trust the certificate.
|
||||||
|
cp $config_fqdn-crt.pem /usr/local/share/ca-certificates/$config_fqdn.crt
|
||||||
|
update-ca-certificates -v
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
nexus_domain=$(hostname --fqdn)
|
||||||
|
|
||||||
# use the local nexus user database.
|
# use the local nexus user database.
|
||||||
config_authentication='nexus'
|
config_authentication='nexus'
|
||||||
|
|
@ -57,7 +58,7 @@ popd
|
||||||
if [ "$config_authentication" = 'ldap' ]; then
|
if [ "$config_authentication" = 'ldap' ]; then
|
||||||
echo '192.168.56.2 dc.example.com' >>/etc/hosts
|
echo '192.168.56.2 dc.example.com' >>/etc/hosts
|
||||||
openssl x509 -inform der -in /vagrant/shared/ExampleEnterpriseRootCA.der -out /usr/local/share/ca-certificates/ExampleEnterpriseRootCA.crt
|
openssl x509 -inform der -in /vagrant/shared/ExampleEnterpriseRootCA.der -out /usr/local/share/ca-certificates/ExampleEnterpriseRootCA.crt
|
||||||
update-ca-certificates
|
update-ca-certificates -v
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,11 +87,11 @@ apt-get install -y --no-install-recommends httpie
|
||||||
apt-get install -y --no-install-recommends jq
|
apt-get install -y --no-install-recommends jq
|
||||||
|
|
||||||
# wait for nexus to come up.
|
# wait for nexus to come up.
|
||||||
bash -c 'while [[ "$(wget -qO- http://localhost:8081/service/extdirect/poll/rapture_State_get | jq -r .data.data.status.value.edition)" != "OSS" ]]; do sleep 5; done'
|
bash -c "while [[ \"\$(wget -qO- https://$nexus_domain/service/extdirect/poll/rapture_State_get | jq -r .data.data.status.value.edition)\" != 'OSS' ]]; do sleep 5; done"
|
||||||
|
|
||||||
# print the version using the API.
|
# print the version using the API.
|
||||||
wget -qO- http://localhost:8081/service/extdirect/poll/rapture_State_get | jq --raw-output .data.data.uiSettings.value.title
|
wget -qO- https://$nexus_domain/service/extdirect/poll/rapture_State_get | jq --raw-output .data.data.uiSettings.value.title
|
||||||
wget -qO- http://localhost:8081/service/extdirect/poll/rapture_State_get | jq .data.data.status.value
|
wget -qO- https://$nexus_domain/service/extdirect/poll/rapture_State_get | jq .data.data.status.value
|
||||||
|
|
||||||
# configure nexus with the groovy script.
|
# configure nexus with the groovy script.
|
||||||
bash /vagrant/provision/execute-provision.groovy-script.sh
|
bash /vagrant/provision/execute-provision.groovy-script.sh
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
nexus_domain=$(hostname --fqdn)
|
||||||
|
|
||||||
mkdir -p tmp/use-maven-repository-from-gradle && cd tmp/use-maven-repository-from-gradle
|
mkdir -p tmp/use-maven-repository-from-gradle && cd tmp/use-maven-repository-from-gradle
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -61,7 +63,7 @@ uploadArchives {
|
||||||
EOF
|
EOF
|
||||||
gradle build
|
gradle build
|
||||||
unzip -l build/libs/gradle-greeter-1.0.0.jar
|
unzip -l build/libs/gradle-greeter-1.0.0.jar
|
||||||
export NEXUS_REPOSITORY_URL='http://localhost:8081/repository/maven-releases'
|
export NEXUS_REPOSITORY_URL="https://$nexus_domain/repository/maven-releases"
|
||||||
export NEXUS_REPOSITORY_USERNAME='alice.doe'
|
export NEXUS_REPOSITORY_USERNAME='alice.doe'
|
||||||
export NEXUS_REPOSITORY_PASSWORD='password'
|
export NEXUS_REPOSITORY_PASSWORD='password'
|
||||||
gradle upload
|
gradle upload
|
||||||
|
|
@ -81,7 +83,7 @@ EOF
|
||||||
cat >settings.gradle <<'EOF'
|
cat >settings.gradle <<'EOF'
|
||||||
rootProject.name = 'gradle-greeter-application'
|
rootProject.name = 'gradle-greeter-application'
|
||||||
EOF
|
EOF
|
||||||
cat >build.gradle <<'EOF'
|
cat >build.gradle <<EOF
|
||||||
// see https://docs.gradle.org/4.2.1/userguide/java_plugin.html
|
// see https://docs.gradle.org/4.2.1/userguide/java_plugin.html
|
||||||
// see https://docs.gradle.org/4.2.1/userguide/application_plugin.html
|
// see https://docs.gradle.org/4.2.1/userguide/application_plugin.html
|
||||||
// see http://imperceptiblethoughts.com/shadow/
|
// see http://imperceptiblethoughts.com/shadow/
|
||||||
|
|
@ -109,7 +111,7 @@ jar {
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url 'http://localhost:8081/repository/maven-public'
|
url 'https://$nexus_domain/repository/maven-public'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
nexus_domain=$(hostname --fqdn)
|
||||||
|
|
||||||
mkdir -p tmp/use-maven-repository-from-mvn && cd tmp/use-maven-repository-from-mvn
|
mkdir -p tmp/use-maven-repository-from-mvn && cd tmp/use-maven-repository-from-mvn
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -16,7 +18,7 @@ sudo apt-get install -y xmlstarlet
|
||||||
# see https://help.sonatype.com/display/NXRM3/Maven+Repositories
|
# see https://help.sonatype.com/display/NXRM3/Maven+Repositories
|
||||||
# see https://maven.apache.org/guides/mini/guide-mirror-settings.html
|
# see https://maven.apache.org/guides/mini/guide-mirror-settings.html
|
||||||
mkdir -p ~/.m2
|
mkdir -p ~/.m2
|
||||||
cat >~/.m2/settings.xml <<'EOF'
|
cat >~/.m2/settings.xml <<EOF
|
||||||
<settings>
|
<settings>
|
||||||
<servers>
|
<servers>
|
||||||
<server>
|
<server>
|
||||||
|
|
@ -29,7 +31,7 @@ cat >~/.m2/settings.xml <<'EOF'
|
||||||
<mirror>
|
<mirror>
|
||||||
<id>nexus</id>
|
<id>nexus</id>
|
||||||
<mirrorOf>central</mirrorOf>
|
<mirrorOf>central</mirrorOf>
|
||||||
<url>http://localhost:8081/repository/maven-public/</url>
|
<url>https://$nexus_domain/repository/maven-public/</url>
|
||||||
</mirror>
|
</mirror>
|
||||||
</mirrors>
|
</mirrors>
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
@ -77,21 +79,21 @@ xmlstarlet ed --inplace -N pom=http://maven.apache.org/POM/4.0.0 \
|
||||||
--name distributionManagement \
|
--name distributionManagement \
|
||||||
--value '@@repositories@@' \
|
--value '@@repositories@@' \
|
||||||
pom.xml
|
pom.xml
|
||||||
python -c '
|
python -c "
|
||||||
xml = open("pom.xml").read().replace("@@repositories@@", """
|
xml = open('pom.xml').read().replace('@@repositories@@', '''
|
||||||
<repository>
|
<repository>
|
||||||
<id>nexus</id>
|
<id>nexus</id>
|
||||||
<name>Releases</name>
|
<name>Releases</name>
|
||||||
<url>http://localhost:8081/repository/maven-releases</url>
|
<url>https://$nexus_domain/repository/maven-releases</url>
|
||||||
</repository>
|
</repository>
|
||||||
<snapshotRepository>
|
<snapshotRepository>
|
||||||
<id>nexus</id>
|
<id>nexus</id>
|
||||||
<name>Snapshot</name>
|
<name>Snapshot</name>
|
||||||
<url>http://localhost:8081/repository/maven-snapshots</url>
|
<url>https://$nexus_domain/repository/maven-snapshots</url>
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
""")
|
''')
|
||||||
open("pom.xml", "w").write(xml)
|
open('pom.xml', 'w').write(xml)
|
||||||
'
|
"
|
||||||
# deploy.
|
# deploy.
|
||||||
mvn \
|
mvn \
|
||||||
--batch-mode \
|
--batch-mode \
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
nexus_domain=$(hostname --fqdn)
|
||||||
|
|
||||||
mkdir -p tmp/use-npm-repository && cd tmp/use-npm-repository
|
mkdir -p tmp/use-npm-repository && cd tmp/use-npm-repository
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -16,10 +18,14 @@ apt-get install -y nodejs
|
||||||
node --version
|
node --version
|
||||||
npm --version
|
npm --version
|
||||||
|
|
||||||
|
# configure npm to trust our system trusted CAs.
|
||||||
|
# NB never turn off ssl verification with npm config set strict-ssl false
|
||||||
|
npm config set cafile /etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
||||||
#
|
#
|
||||||
# configure npm to use the npm-group repository.
|
# configure npm to use the npm-group repository.
|
||||||
|
|
||||||
npm config set registry http://localhost:8081/repository/npm-group/
|
npm config set registry https://$nexus_domain/repository/npm-group/
|
||||||
|
|
||||||
# install a package that indirectly uses the npmjs.org-proxy repository.
|
# install a package that indirectly uses the npmjs.org-proxy repository.
|
||||||
mkdir hello-world-npm
|
mkdir hello-world-npm
|
||||||
|
|
@ -52,10 +58,10 @@ node hello-world.js
|
||||||
export NPM_USER=alice.doe
|
export NPM_USER=alice.doe
|
||||||
export NPM_PASS=password
|
export NPM_PASS=password
|
||||||
export NPM_EMAIL=alice.doe@example.com
|
export NPM_EMAIL=alice.doe@example.com
|
||||||
export NPM_REGISTRY=http://localhost:8081/repository/npm-hosted/
|
export NPM_REGISTRY=https://$nexus_domain/repository/npm-hosted/
|
||||||
npm install npm-registry-client@8.5.0
|
npm install npm-registry-client@8.5.0
|
||||||
npm_auth_token=$(NODE_PATH=$PWD/node_modules node /vagrant/provision/npm-login.js 2>/dev/null)
|
npm_auth_token=$(NODE_PATH=$PWD/node_modules node --use-openssl-ca /vagrant/provision/npm-login.js 2>/dev/null)
|
||||||
npm set //localhost:8081/repository/npm-hosted/:_authToken $npm_auth_token
|
npm set //$nexus_domain/repository/npm-hosted/:_authToken $npm_auth_token
|
||||||
|
|
||||||
# publish.
|
# publish.
|
||||||
npm publish --registry=$NPM_REGISTRY
|
npm publish --registry=$NPM_REGISTRY
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
nexus_domain=$(hostname --fqdn)
|
||||||
|
|
||||||
. /vagrant/provision/nexus-groovy.sh
|
. /vagrant/provision/nexus-groovy.sh
|
||||||
|
|
||||||
mkdir -p tmp/use-nuget-repository && cd tmp/use-nuget-repository
|
mkdir -p tmp/use-nuget-repository && cd tmp/use-nuget-repository
|
||||||
|
|
@ -20,8 +22,8 @@ function nuget {
|
||||||
mono /tmp/nuget.exe $*
|
mono /tmp/nuget.exe $*
|
||||||
}
|
}
|
||||||
|
|
||||||
nuget_source_url=http://localhost:8081/repository/nuget-group/
|
nuget_source_url=https://$nexus_domain/repository/nuget-group/
|
||||||
nuget_source_push_url=http://localhost:8081/repository/nuget-hosted/
|
nuget_source_push_url=https://$nexus_domain/repository/nuget-hosted/
|
||||||
nuget_source_push_api_key=$(nexus-groovy get-jenkins-nuget-api-key | jq -r '.result | fromjson | .apiKey')
|
nuget_source_push_api_key=$(nexus-groovy get-jenkins-nuget-api-key | jq -r '.result | fromjson | .apiKey')
|
||||||
echo -n $nuget_source_push_api_key >/vagrant/shared/jenkins-nuget-api-key
|
echo -n $nuget_source_push_api_key >/vagrant/shared/jenkins-nuget-api-key
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
nexus_domain=$(hostname --fqdn)
|
||||||
|
|
||||||
mkdir -p tmp/use-raw-repository && cd tmp/use-raw-repository
|
mkdir -p tmp/use-raw-repository && cd tmp/use-raw-repository
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -12,8 +14,8 @@ apt-get install -y curl
|
||||||
# see https://help.sonatype.com/display/NXRM3/Raw+Repositories+and+Maven+Sites#RawRepositoriesandMavenSites-UploadingFilestoHostedRawRepositories
|
# see https://help.sonatype.com/display/NXRM3/Raw+Repositories+and+Maven+Sites#RawRepositoriesandMavenSites-UploadingFilestoHostedRawRepositories
|
||||||
expected='this is an adhoc package'
|
expected='this is an adhoc package'
|
||||||
echo "$expected" >package-1.0.0.txt
|
echo "$expected" >package-1.0.0.txt
|
||||||
curl --silent --user 'alice.doe:password' --upload-file package-1.0.0.txt http://localhost:8081/repository/adhoc-package/package-1.0.0.txt
|
curl --silent --user 'alice.doe:password' --upload-file package-1.0.0.txt https://$nexus_domain/repository/adhoc-package/package-1.0.0.txt
|
||||||
|
|
||||||
# download.
|
# download.
|
||||||
actual=$(curl --silent http://localhost:8081/repository/adhoc-package/package-1.0.0.txt)
|
actual=$(curl --silent https://$nexus_domain/repository/adhoc-package/package-1.0.0.txt)
|
||||||
[ "$actual" = "$expected" ] || (echo 'upload adhoc package test failed' && false)
|
[ "$actual" = "$expected" ] || (echo 'upload adhoc package test failed' && false)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue