Last active
November 2, 2018 09:54
-
-
Save javaguirre/24130c063131f7c5a0bee1022b4ebdac to your computer and use it in GitHub Desktop.
CI/CD Hyperledger Fabric Chaincode in Golang, Gitlab CI. Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- test | |
- deploy | |
test: | |
stage: test | |
image: golang:1.10 | |
script: | |
- go get -v -u github.com/hyperledger/fabric-sdk-go | |
- go get -v -u github.com/stretchr/testify/assert | |
- mkdir -p $GOPATH/src/gitlab.com/myproject/ngo | |
- cp -r /builds/myproject/myrepository/chaincode/chaincode_name/* $GOPATH/src/gitlab.com/myproject/chaincode_name | |
# Build hyperledger fabric | |
- apt-get update && apt-get install -y libltdl-dev | |
- mkdir -p $GOPATH/src/github.com/hyperledger | |
- cd $GOPATH/src/github.com/hyperledger | |
- git clone -b master https://github.com/hyperledger/fabric.git | |
- cd $GOPATH/src/gitlab.com/myproject/chaincode_name | |
- go test -v . | |
deploy_staging: | |
stage: deploy | |
script: | |
- "curl -X POST https://$NETWORK_STAGING_KEY:$NETWORK_STAGING_PASS@blockchain-starter.eu-gb.bluemix.net/api/v1/networks/$NETWORK_STAGING_ID/chaincode/install -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F 'files=@chaincode/chaincode_name/chaincode_name.go' -F 'chaincode_id=chaincode_name' -F \"chaincode_version=$CI_COMMIT_SHA\" -F 'chaincode_type=golang'" | |
- "curl -X POST https://$NETWORK_STAGING_KEY:$NETWORK_STAGING_PASS@blockchain-starter.eu-gb.bluemix.net/api/v1/networks/$NETWORK_STAGING_ID/channels/$CHANNEL_STAGING_ID/chaincode/instantiate -H 'accept: application/json' -H 'Content-Type: application/json' --data '{ \"chaincode_id\": \"chaincode_name\", \"chaincode_version\": \"'\"$CI_COMMIT_SHA\"'\", \"chaincode_type\": \"golang\", \"chaincode_arguments\": [], \"endorsement_policy\": { \"identities\": [ { \"role\": { \"name\": \"member\", \"mspId\": \"org1\" } }, { \"role\": { \"name\": \"member\", \"mspId\": \"org2\" } } ], \"policy\": { \"1-of\": [ { \"signed-by\": 0 }, { \"signed-by\": 1 } ] } }}'" | |
only: | |
- master | |
deploy_production: | |
stage: deploy | |
script: | |
- "curl -X POST https://$NETWORK_KEY:$NETWORK_PASS@blockchain-starter.eu-gb.bluemix.net/api/v1/networks/$NETWORK_ID/chaincode/install -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F 'files=@chaincode/chaincode_name/chaincode_name.go' -F 'chaincode_id=chaincode_name' -F \"chaincode_version=$CI_COMMIT_TAG\" -F 'chaincode_type=golang'" | |
- "curl -X POST https://$NETWORK_KEY:$NETWORK_PASS@blockchain-starter.eu-gb.bluemix.net/api/v1/networks/$NETWORK_ID/channels/$CHANNEL_ID/chaincode/instantiate -H 'accept: application/json' -H 'Content-Type: application/json' --data '{ \"chaincode_id\": \"chaincode_name\", \"chaincode_version\": \"'\"$CI_COMMIT_TAG\"'\", \"chaincode_type\": \"golang\", \"chaincode_arguments\": [], \"endorsement_policy\": { \"identities\": [ { \"role\": { \"name\": \"member\", \"mspId\": \"org1\" } }, { \"role\": { \"name\": \"member\", \"mspId\": \"org2\" } } ], \"policy\": { \"1-of\": [ { \"signed-by\": 0 }, { \"signed-by\": 1 } ] } }}'" | |
only: | |
- tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment