Skip to content

Commit 7f3c4e3

Browse files
jt-ntimbwhite
authored andcommitted
[FAB-17138] Publish docker images to nexus
Signed-off-by: James Taylor <[email protected]>
1 parent b52d26a commit 7f3c4e3

File tree

2 files changed

+58
-38
lines changed

2 files changed

+58
-38
lines changed

ci/azure-pipelines.yml

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Copyright IBM Corp. All Rights Reserved.
32
#
43
# SPDX-License-Identifier: Apache-2.0
@@ -15,31 +14,26 @@ schedules:
1514
branches:
1615
include:
1716
- master
18-
- release-1.4
1917
always: true
2018

21-
# Trigger on master, release-1.4 and git tags
2219
trigger:
2320
branches:
2421
include:
2522
- "master"
26-
- "release-1.4"
2723
tags:
2824
include:
2925
- "*"
3026

31-
# These are custom defined variables, the pipeline one is currently used for the build scripts
32-
# to know to produce tests results in XML format for Azure to consume, for developers
33-
# this isn't set so command line output is given
34-
#
3527
# These are custom defined variables, the pipeline one is currently used for the build scripts
3628
# to know to produce tests results in XML format for Azure to consume, for developers
3729
# this isn't set so command line output is given
3830
#
3931
# Chaincode_Java_Creds is the protected group of keys for publishing
32+
#
4033
variables:
4134
- group: Chaincode_Java_Creds
42-
- group: GitHubRegistry
35+
- group: Github-PackageRegistry-Credentials
36+
- group: JARSigningPublish
4337
- name: component
4438
value: fabric-chaincode-java
4539
- name: pipeline
@@ -52,16 +46,15 @@ variables:
5246
pool:
5347
vmImage: "ubuntu-latest"
5448

55-
#
5649
# The stages and jobs, potential for rationalization and optimization
5750
# Keeping it simple and explict whilst we gain experience
51+
#
5852
stages:
5953
- stage: Build_and_test
6054
jobs:
6155
- job: main
62-
steps:
63-
- script: |
64-
env | sort
56+
steps:
57+
- template: templates/build-data.yml
6558
- task: Gradle@2
6659
inputs:
6760
workingDirectory: ""
@@ -90,7 +83,7 @@ stages:
9083
- task: PublishBuildArtifacts@1
9184
inputs:
9285
pathToPublish: $(Build.ArtifactStagingDirectory)/fabric-javaenv.tar.gz
93-
artifactName: javaenv-docker-image
86+
artifactName: javaenv-docker-image
9487

9588
- job: javadoc
9689
condition: and(succeeded(),eq(variables['Build.Reason'], 'IndividualCI'))
@@ -129,47 +122,64 @@ stages:
129122
- job: snapshot_publish
130123
dependsOn: main
131124
condition: and(succeeded(),eq(variables['Build.Reason'], 'IndividualCI'))
125+
variables:
126+
PACKAGE_VERSION: $[ dependencies.main.outputs['BuildData.PACKAGE_VERSION'] ]
132127
steps:
133128
- task: DownloadPipelineArtifact@2
134129
inputs:
135-
artifact: java-docker-image
130+
artifact: javaenv-docker-image
136131
path: $(Build.SourcesDirectory)/build
137132
- script: |
138-
docker image load --input build/fabric-javaenv.tar.gz # gets the build image of nodeenv
133+
docker image load --input build/fabric-javaenv.tar.gz
139134
docker images
140135
# Publish docker images to nexus repository
141136
docker login ${DOCKER_REGISTRY_URL} --username=${DOCKER_REGISTRY_USERNAME} --password=${DOCKER_REGISTRY_PASSWORD}
142137
echo "Logged in to docker registry"
143138
# tag javaenv image to $PUSH_VERSION
144-
docker tag hyperledger/fabric-javaenv ${DOCKER_REGISTRY_URL}/fabric-javaenv:amd64-${MAPPED_VERSION}
139+
docker tag hyperledger/fabric-javaenv ${DOCKER_REGISTRY_URL}/fabric-javaenv:amd64-${MAPPED_VERSION}-stable
145140
# push javaenv to nexus repository
146-
docker push ${DOCKER_REGISTRY_URL}/fabric-javaenv:amd64-${MAPPED_VERSION}
147-
env:
148-
DOCKER_REGISTRY_USERNAME: $(GITHUB_REGISTRY_USER)
149-
DOCKER_REGISTRY_PASSWORD: $(GITHUB_REGISTRY_PWD_TOKEN)
150-
DOCKER_REGISTRY_URL: docker.pkg.github.com/hyperledger/fabric-chaincode-java
151-
MAPPED_VERSION: $(PUSH_VERSION)
141+
docker push ${DOCKER_REGISTRY_URL}/fabric-javaenv:amd64-${MAPPED_VERSION}-stable
142+
env:
143+
DOCKER_REGISTRY_USERNAME: $(nexus-user)
144+
DOCKER_REGISTRY_PASSWORD: $(nexus-password)
145+
DOCKER_REGISTRY_URL: nexus3.hyperledger.org:10003/hyperledger
146+
MAPPED_VERSION: $(PACKAGE_VERSION)
147+
displayName: 'docker push to nexus'
152148
153149
# As the next script is more complex and uses loops, run this descretely in a sh file
154150
# Publishing step for git tags
155151
- stage: Publish_tag
156152
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags'))
157153
jobs:
158-
- job: update_version
159-
steps:
160-
- script: |
161-
env | sort
162-
echo "Update the version number"
163-
echo "Make sure release notes are present"
164-
echo "Make sure change history is present"
165-
- job: npm_publish
154+
- job: publish_release
166155
steps:
156+
- template: templates/build-data.yml
157+
- task: DownloadPipelineArtifact@2
158+
inputs:
159+
artifact: javaenv-docker-image
160+
path: $(Build.SourcesDirectory)/build
161+
- task: DownloadSecureFile@1
162+
name: keyring
163+
inputs:
164+
secureFile: secring.gpg
167165
- script: |
168-
echo "Setup .npmrc"
169-
echo "Use pipeline secret to login"
170-
echo "publish"
171-
- job: jsdoc_publish
172-
steps:
166+
docker image load --input build/fabric-javaenv.tar.gz
167+
docker images
168+
# Publish docker images to nexus repository
169+
docker login ${DOCKER_REGISTRY_URL} --username=${DOCKER_REGISTRY_USERNAME} --password=${DOCKER_REGISTRY_PASSWORD}
170+
echo "Logged in to docker registry"
171+
# tag javaenv image to PACKAGE_VERSION
172+
docker tag hyperledger/fabric-javaenv fabric-javaenv:amd64-$(BuildData.PACKAGE_VERSION)
173+
# push javaenv to repository
174+
docker push hyperledger/fabric-javaenv:amd64-$(BuildData.PACKAGE_VERSION)
175+
env:
176+
DOCKER_REGISTRY_USERNAME: $(DockerHub-Username)
177+
DOCKER_REGISTRY_PASSWORD: $(DockerHub-Password)
173178
- script: |
174-
echo "checkout docs branch"
175-
echo "checking"
179+
./gradlew -Psigning.keyId=${SIGNING_ID} -Psigning.password=${SIGNING_PASSWORD} -Psigning.secretKeyRingFile=${KEYRING_FILE} -PossrhUsername=${OSSRH_USER} -PossrhPassword=${OSSRH_PASSWORD} uploadArchives
180+
env:
181+
SIGNING_ID: $(JAR-Signing-Id)
182+
SIGNING_PASSWORD: $(JAR-Signing-Password)
183+
KEYRING_FILE: $(keyring.secureFilePath)
184+
OSSRH_USER: $(OSSRH-User)
185+
OSSRH_PASSWORD: $(OSSRH-Password)

ci/templates/build-data.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
steps:
2+
- script: |
3+
env | sort
4+
java -version
5+
VERSION=$(cat build.gradle | sed -n "s/version =.*'\(.*\)\(-SNAPSHOT\)\?'/\1/p")
6+
VERSION=${VERSION// }
7+
echo Current version in code is :${VERSION}:
8+
echo "##vso[task.setvariable variable=PACKAGE_VERSION;isOutput=true]${VERSION}"
9+
name: BuildData
10+
displayName: 'Build data'

0 commit comments

Comments
 (0)