First we need to register to Gogs as a developer. For uniformity, we use the following convention:
Important: Use the correct value of userX
username: userX email: userX@example.com password: userX
Click the + sign of My Repositories. Set the following details:
Click Create Repository
Copy the new repository url to the clipboard
git clone https://github.com/corpbob/todoAPIjs.git
cd todoAPIjs
git remote add gogs <your gogs todoAPIjs repository url>
git push gogs master
You should be able to see something like this
Set the following parameters to the specified values:
Click “Add to Project”, search for NodeJs
Input the details as shown below. The project should be the project assigned to you.
Click on “advanced options”. Scroll to Deployment Configuration and add Environment Variable
PORT = 8080
Click on Create.
The build will fail in this case because the repository is private.
oc project
oc secrets new-basicauth gogs-secret --username=<your gogs username> --password=<your gogs password>
Configure the deployment config to use this secret.
apiVersion: v1
kind: BuildConfig
metadata:
labels:
app: jenkins-pipeline-example
name: sample-pipeline
template: application-template-sample-pipeline
name: todo-pipeline
spec:
runPolicy: Serial
strategy:
jenkinsPipelineStrategy:
jenkinsfile: |-
node('nodejs') {
stage('build') {
openshiftBuild(buildConfig: 'todo', showBuildLogs: 'true')
}
stage('deploy') {
openshiftDeploy(deploymentConfig: 'todo')
}
//stage( 'Wait for approval')
//input( 'Aprove to production?')
//stage('Deploy UAT'){
//openshiftDeploy(deploymentConfig: 'todo', namespace: 'todo-uat')
//}
}
type: JenkinsPipeline
triggers:
- github:
secret: secret101
type: GitHub
- generic:
secret: secret101
type: Generic
oc create -f todo_pipeline.yml
Next Exercise: Configure the CI/CD pipeline
Written on December 20th, 2017 by Bobby Corpus