-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
100 lines (92 loc) · 4.02 KB
/
Copy pathJenkinsfile
File metadata and controls
100 lines (92 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
pipeline {
agent any
stages {
stage('Clone repository') {
steps {
checkout scm
}
}
stage ('Build & Push ') {
steps {
echo 'Building'
sh 'ls -ltra'
script {
def app
app = docker.build("safficodefresh/test-report-image-jenkins")
// require credentials to be stored under DOCKERHUB
docker.withRegistry('https://registry.hub.docker.com', 'DOCKERHUB') {
app.push("${env.BUILD_NUMBER}")
app.push("latest")
}
}
sh '''
IMAGE_NAME="safficodefresh/test-report-image-jenkins:$BUILD_NUMBER"
docker pull $IMAGE_NAME
'''
}
}
stage('report image') {
environment {
CF_ENRICHERS = 'jira git'
CF_HOST = 'https://saffi.pipeline-team.cf-cd.com'
CF_API_KEY = credentials('CF_API_KEY')
CF_IMAGE = "safficodefresh/test-report-image-jenkins:${env.BUILD_NUMBER}"
CF_CONTAINER_REGISTRY_INTEGRATION= 'docker'
CF_JIRA_INTEGRATION= 'jira'
CF_JIRA_MESSAGE= '''
A message with embedded issue ( i.e. CR-11027 )
that would be use query jira for the ticket '''
CF_JIRA_PROJECT_PREFIX = 'CR'
CF_WORKFLOW_NAME = "${env.JOB_NAME}"
CF_WORKFLOW_URL = "${env.BUILD_URL}"
CF_GITHUB_TOKEN = credentials('CF_GITHUB_TOKEN')
// CF_GITHUB_API_HOST_URL = "https://api.github.com" // Thats the default github service api
// CF_GITHUB_API_PATH_PREFIX = "" // default empty - no prefix
CF_CI_TYPE = "jenkins"
CF_GIT_REPO = "saffi-codefresh/example-jenkins-use-codefresh-report-image"
CF_GIT_PROVIDER = "github"
}
agent {
docker {
registryUrl 'https://quay.io'
registryCredentialsId 'quay-id'
image "quay.io/codefresh/codefresh-report-image:0.0.83"
}
}
steps {
sh '''
# add git branch
export CF_GIT_BRANCH="${GIT_BRANCH#*/}"
echo "CF_GIT_BRANCH is $CF_GIT_BRANCH"
echo $(env)
node --version
cd /code && yarn start'''
}
// Alternative implementation
// steps {
// sh '''
// # add git branch
// export CF_BRANCH="${GIT_BRANCH#*/}"
// env | cut -f 1 -d "=" | grep -E "^CF_" > cf_env
// echo "using $(cat cd_env|xargs echo)"
// # docker run --env-file=cf_env "quay.io/codefresh/codefresh-report-image:$VERSION"
// VERSION="a0.0.3"
// docker run --env-file=cf_env "safficodefresh/codefresh-report-image:$VERSION"
// '''
// }
// VERSION="0.0.80"
// KEYS=($(jq -n 'env' -S -M -c | jq 'keys' -M -c))
// arr=()
// for i in $(echo $KEYS | tr "[" "\n" | tr "]" "\n" | tr '"' '\n' | tr "," "\n")
// do
// if [[ $i == CF_* ]]
// then
// arr+=" -e $i "
// fi
// done
// # echo "$arr"
// # docker run $arr "quay.io/codefresh/codefresh-report-image:$VERSION"
// docker run $arr saffi-codefresh/codefresh-report-image:a0.0.4
}
}
}