Skip to content

Commit db86f5a

Browse files
author
Arthur She
committed
Add "TF OpenCI:" to the githubNotify context if build job runs on Open CI
Signed-off-by: Arthur She <[email protected]>
1 parent 6f0724a commit db86f5a

File tree

7 files changed

+38
-13
lines changed

7 files changed

+38
-13
lines changed

resources/docker_files/ubuntu-16.04/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ RUN wget -q https://developer.arm.com/-/media/Files/downloads/compiler/DS500-PA-
117117

118118
ENV ARMC5_BIN_DIR=/usr/local/ARM_Compiler_5.06u3/bin/
119119
ENV PATH=$PATH:/usr/local/ARM_Compiler_5.06u3/bin
120-
120+
121+
ENV ARMLMD_LICENSE_FILE=${ARMLMD_LICENSE_FILE}
121122

122123
# Install ARM Compiler 6.6
123124
RUN mkdir temp && cd temp && \

resources/docker_files/ubuntu-18.04/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ RUN wget -q https://developer.arm.com/-/media/Files/downloads/compiler/DS500-PA-
101101

102102
ENV ARMC5_BIN_DIR=/usr/local/ARM_Compiler_5.06u3/bin/
103103
ENV PATH=$PATH:/usr/local/ARM_Compiler_5.06u3/bin
104-
104+
105+
ENV ARMLMD_LICENSE_FILE=${ARMLMD_LICENSE_FILE}
105106

106107
# Install ARM Compiler 6.6
107108
RUN mkdir temp && cd temp && \

vars/common.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import groovy.transform.Field
7777

7878
/* Maps platform names to the tag of the docker image used to test that platform.
7979
* Populated by init_docker_images() / gen_jobs.gen_dockerfile_builder_job(platform). */
80-
@Field docker_tags = is_open_ci_env ? [('ubuntu-16.04'):'xenial', ('ubuntu-18.04'):'bionic'] : [:]
80+
@Field static docker_tags = [:]
8181

8282
/* Compute the git object ID of the Dockerfile.
8383
* Equivalent to the `git hash-object <file>` command. */
@@ -238,7 +238,8 @@ def maybe_notify_github(context, state, description) {
238238
description = description.take(MAX_DESCRIPTION_LENGTH - 1) + ''
239239
}
240240

241-
githubNotify context: "${env.BRANCH_NAME} ${context}",
241+
content = is_open_ci_env ? "TF OpenCI: ${env.BRANCH_NAME} ${context}" : "${env.JENKINS_URL} ${env.BRANCH_NAME} ${context}"
242+
githubNotify context: content,
242243
status: state,
243244
description: description
244245
}

vars/gen_jobs.groovy

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import groovy.transform.Field
2525
//Record coverage details for reporting
2626
@Field coverage_details = ['coverage': 'Code coverage job did not run']
2727

28+
@Field armlmd_license_file = common.is_open_ci_env ? "[email protected]" : "[email protected]:[email protected]:[email protected]:[email protected]"
29+
2830
def gen_simple_windows_jobs(label, script) {
2931
def jobs = [:]
3032

@@ -163,7 +165,6 @@ def gen_all_sh_jobs(platform, component, label_prefix='') {
163165
def use_docker = platform_has_docker(platform)
164166
def extra_setup_code = ''
165167
def node_label = node_label_for_platform(platform)
166-
def armlmd_license_file = common.is_open_ci_env ? "[email protected]" : "[email protected]:[email protected]:[email protected]:[email protected]"
167168

168169
if (platform_lacks_tls_tools(platform)) {
169170
/* The check_tools function in all.sh insists on the existence of the
@@ -621,6 +622,9 @@ def gen_dockerfile_builder_job(platform, overwrite=false) {
621622
def dockerfile = libraryResource "docker_files/$platform/Dockerfile"
622623

623624
def tag = "$platform-${common.git_hash_object(dockerfile)}"
625+
def check_docker_image = "aws ecr describe-images --repository-name $common.docker_repo_name --image-ids imageTag=$tag"
626+
def check_docker_image_open_ci = "docker manifest inspect $common.docker_repo:$tag > /dev/null 2>&1"
627+
624628
common.docker_tags[platform] = tag
625629

626630
jobs[platform] = {
@@ -629,18 +633,38 @@ def gen_dockerfile_builder_job(platform, overwrite=false) {
629633
node('dockerfile-builder') {
630634
def image_exists = false
631635
if (!overwrite) {
632-
def test_image_exists_sh = "aws ecr describe-images --repository-name $common.docker_repo_name --image-ids imageTag=$tag"
636+
def test_image_exists_sh = common.is_open_ci_env ? check_docker_image_open_ci : check_docker_image
633637
image_exists = sh(script: test_image_exists_sh, returnStatus: true) == 0
634638
}
635639
if (overwrite || !image_exists) {
636640
dir('docker') {
637641
deleteDir()
638642
writeFile file: 'Dockerfile', text: dockerfile
639-
sh """\
643+
if (common.is_open_ci_env) {
644+
withCredentials([string(credentialsId: 'DOCKER_AUTH', variable: 'TOKEN')]) {
645+
sh """\
646+
mkdir -p ${env.HOME}/.docker
647+
cat > ${env.HOME}/.docker/config.json << EOF
648+
{
649+
"auths": {
650+
"https://index.docker.io/v1/": {
651+
"auth": '${TOKEN}'
652+
}
653+
}
654+
}
655+
EOF
656+
chmod 0600 ${env.HOME}/.docker/config.json
657+
docker build --build-arg ARMLMD_LICENSE_FILE=$armlmd_license_file -t $common.docker_repo:$tag .
658+
docker push $common.docker_repo:$tag
659+
"""
660+
}
661+
} else {
662+
sh """\
640663
docker build -t $common.docker_repo:$tag .
641664
aws ecr get-login-password | docker login --username AWS --password-stdin $common.docker_ecr
642665
docker push $common.docker_repo:$tag
643666
"""
667+
}
644668
}
645669
}
646670
}

vars/mbed_os_example.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
def run_pr_job(example, is_production=true) {
2121
timestamps {
2222
environ.set_mbed_os_example_pr_environment(example, is_production)
23-
if (!common.is_open_ci_env)
24-
common.init_docker_images()
23+
common.init_docker_images()
2524
def jobs = gen_jobs.gen_all_example_jobs()
2625
jobs.failFast = false
2726
parallel jobs

vars/mbedtls-release-Jenkinsfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ environ.set_tls_release_environment()
4545

4646
timestamps {
4747
try {
48-
if (!common.is_open_ci_env)
49-
common.init_docker_images()
48+
common.init_docker_images()
5049
stage('tls-testing') {
5150
def jobs = gen_jobs.gen_release_jobs()
5251
common.run_release_jobs(

vars/mbedtls.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ def run_pr_job(is_production=true) {
9696
'In progress'
9797
common.maybe_notify_github "Result analysis", 'PENDING',
9898
'In progress'
99-
if (!common.is_open_ci_env)
100-
common.init_docker_images()
99+
100+
common.init_docker_images()
101101

102102
stage('pre-test-checks') {
103103
try {

0 commit comments

Comments
 (0)