Skip to content

Instantly share code, notes, and snippets.

@javaguirre javaguirre/.gitlab-ci.yml
Last active Nov 2, 2018

Embed
What would you like to do?
CI/CD Hyperledger Fabric Chaincode in Golang, Gitlab CI. Example
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
You can’t perform that action at this time.