visit
<span style="box-sizing: border-box; color: rgb(153, 153, 153);">stages {
stage('Build') {
steps {
container('golang'){
sh 'go build'
}
}
}
stage('Unit Tests') {
steps {
container('golang'){
sh 'go test ./... -run Unit'
}
}
}
stage('Docker Build') {
steps {
container('docker'){
sh "docker build -t <a class="vglnk" href="//partnership-public-images.jfrog.io/goci-example:latest" rel="nofollow" style="box-sizing: border-box; color: rgb(64, 190, 70); text-decoration: none; background-color: transparent;"><span style="box-sizing: border-box;">partnership</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">public</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">images</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">jfrog</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">io</span><span style="box-sizing: border-box;">/</span><span style="box-sizing: border-box;">goci</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">example</span><span style="box-sizing: border-box;">:</span><span style="box-sizing: border-box;">latest</span></a> ."
}
}
}
stage('Docker Push to Repo') {
steps {
container('docker'){
script {
docker.withRegistry( '<a class="vglnk" href="//partnership-public-images.jfrog.io/" rel="nofollow" style="box-sizing: border-box; color: rgb(64, 190, 70); text-decoration: none; background-color: transparent;"><span style="box-sizing: border-box;">https</span><span style="box-sizing: border-box;">://</span><span style="box-sizing: border-box;">partnership</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">public</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">images</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">jfrog</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">io</span></a>', 'gociexamplerepo' ) {
sh "docker push <a class="vglnk" href="//partnership-public-images.jfrog.io/goci-example:latest" rel="nofollow" style="box-sizing: border-box; color: rgb(64, 190, 70); text-decoration: none; background-color: transparent;"><span style="box-sizing: border-box;">partnership</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">public</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">images</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">jfrog</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">io</span><span style="box-sizing: border-box;">/</span><span style="box-sizing: border-box;">goci</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">example</span><span style="box-sizing: border-box;">:</span><span style="box-sizing: border-box;">latest</span></a>"
}
}
}
}
}
<span style="box-sizing: border-box; color: rgb(64, 190, 70);">stage('Publish Build Info') {
environment {
JFROG_CLI_OFFER_CONFIG = false
}
steps {
container('jfrog-cli-go'){
withCredentials([usernamePassword(credentialsId: 'gociexamplerepo', passwordVariable: 'APIKEY', usernameVariable: 'USER')]) {
sh "jfrog rt bce $JOB_NAME $BUILD_NUMBER"
sh "jfrog rt bag $JOB_NAME $BUILD_NUMBER"
sh "jfrog rt bad $JOB_NAME $BUILD_NUMBER \"go.*\""
sh "jfrog rt bp --build-url=<a class="vglnk" href="//jenkins.openshiftk8s.com/" rel="nofollow" style="box-sizing: border-box; color: rgb(64, 190, 70); text-decoration: none; background-color: transparent;"><span style="box-sizing: border-box;">https</span><span style="box-sizing: border-box;">://</span><span style="box-sizing: border-box;">jenkins</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">openshiftk8s</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">com</span><span style="box-sizing: border-box;">/</span></a> --url=<a class="vglnk" href="//partnership.jfrog.io/artifactory" rel="nofollow" style="box-sizing: border-box; color: rgb(64, 190, 70); text-decoration: none; background-color: transparent;"><span style="box-sizing: border-box;">https</span><span style="box-sizing: border-box;">://</span><span style="box-sizing: border-box;">partnership</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">jfrog</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">io</span><span style="box-sizing: border-box;">/</span><span style="box-sizing: border-box;">artifactory</span></a> --user=$USER --apikey=$APIKEY $JOB_NAME $BUILD_NUMBER"
}
}
}
}</span>
}</span>
<span style="box-sizing: border-box; color: rgb(153, 153, 153);">post {
success {
script {
sh <span style="box-sizing: border-box; color: rgb(64, 190, 70);">"curl -XPOST -H \"Authorization: Basic amVmabcdefM25rMW5z=\" \"<a class="vglnk" href="//partnership-pipelines-api.jfrog.io/v1/projectIntegrations/17/hook/" rel="nofollow" style="box-sizing: border-box; color: rgb(64, 190, 70); text-decoration: none; background-color: transparent;"><span style="box-sizing: border-box;">https</span><span style="box-sizing: border-box;">://</span><span style="box-sizing: border-box;">partnership</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">pipelines</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">api</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">jfrog</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">io</span><span style="box-sizing: border-box;">/</span><span style="box-sizing: border-box;">v1</span><span style="box-sizing: border-box;">/</span><span style="box-sizing: border-box;">projectIntegrations</span><span style="box-sizing: border-box;">/</span><span style="box-sizing: border-box;">17</span><span style="box-sizing: border-box;">/</span><span style="box-sizing: border-box;">hook</span><span style="box-sizing: border-box;">\</span></a>" -d '{\"buildName\":\"$JOB_NAME\",\"buildNumber\":\"$BUILD_NUMBER\",\"buildInfoResourceName\":\"jenkinsBuildInfo\"}' -H \"Content-Type: application/json\""</span>
}
}
}</span>
<span style="box-sizing: border-box; color: rgb(153, 153, 153);">resources:
- name: gociexampleGithubRepo
type: GitRepo
configuration:
gitProvider: myGithub
path: myaccount/goci-example
<span style="box-sizing: border-box; color: rgb(64, 190, 70);"> - name: jenkinsBuildInfo
type: BuildInfo
configuration:
sourceArtifactory: MyArtifactory
buildName: goci-example/master
buildNumber: 1
externalCI: jenkins_openshiftk8s_com</span>
- name: releaseBuildInfo
type: BuildInfo
configuration:
sourceArtifactory: MyArtifactory
buildName: goci-example/master
buildNumber: 1</span>
<span style="box-sizing: border-box; color: rgb(153, 153, 153);">- name: start_from_jenkins
type: Bash
configuration:
<span style="box-sizing: border-box; color: rgb(64, 190, 70);"> inputResources:
- name: jenkinsBuildInfo</span>
execution:
onExecute:
- echo 'Jenkins job triggered Pipelines'</span>
<span style="box-sizing: border-box; color: rgb(153, 153, 153);">- name: deploy_staging
type: HelmDeploy
configuration:
inputSteps:
- name: start_from_jenkins
inputResources:
- name: gociexampleGithubRepo
trigger: false
integrations:
- name: gociexampleClusterCreds
releaseName: goci-example
chartPath: chart/goci-example/</span>
<span style="box-sizing: border-box; color: rgb(153, 153, 153);">- name: wait_for_server
type: Bash
configuration:
inputSteps:
- name: deploy_staging
execution:
onExecute:
- timeout 60 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' <a class="vglnk" href="//goci-example.35.238.177.209.xip.io/" rel="nofollow" style="box-sizing: border-box; color: rgb(64, 190, 70); text-decoration: none; background-color: transparent;"><span style="box-sizing: border-box;">http</span><span style="box-sizing: border-box;">://</span><span style="box-sizing: border-box;">goci</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">example</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">35</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">238</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">177</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">209</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">xip</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">io</span></a>)" != "200" ]]; do sleep 5; done' || true</span>
<span style="box-sizing: border-box; color: rgb(153, 153, 153);">- name: staging_test
type: Bash
configuration:
inputSteps:
- name: wait_for_server
inputResources:
- name: gociexampleGithubRepo
trigger: false
runtime:
type: image
image:
auto:
language: go
versions:
- "1.13"
environmentVariables:
STAGING_URL: "<a class="vglnk" href="//goci-example.35.238.177.209.xip.io/" rel="nofollow" style="box-sizing: border-box; color: rgb(64, 190, 70); text-decoration: none; background-color: transparent;"><span style="box-sizing: border-box;">http</span><span style="box-sizing: border-box;">://</span><span style="box-sizing: border-box;">goci</span><span style="box-sizing: border-box;">-</span><span style="box-sizing: border-box;">example</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">35</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">238</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">177</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">209</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">xip</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">io</span></a>"
execution:
onExecute:
- cd ../dependencyState/resources/gociexampleGithubRepo
- go mod download
- go test ./test -run Staging</span>
<span style="box-sizing: border-box; color: rgb(153, 153, 153);">- name: promote_release
type: PromoteBuild
configuration:
targetRepository: partnership-public-images.jfrog.io
status: Released
comment: Passed staging tests.
inputResources:
- name: jenkinsBuildInfo
outputResources:
- name: releaseBuildInfo</span>