File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bats
2+
3+ # bats file_tags=test-suite:jenkinsfile
4+
5+ load test_helpers
6+
7+ SUT_DESCRIPTION=" Jenkinsfile"
8+
9+ @test " [${SUT_DESCRIPTION} ] Default (weekly) targets from docker bake are taken in account in Jenkinsfile" {
10+ [ " $( get_default_docker_bake_targets) " == " $( get_targets_from_jenkinsfile) " ]
11+ }
Original file line number Diff line number Diff line change 11#! /bin/bash
2+ set -euo pipefail
23
34# Assert that $1 is the outputof a command $2
45function assert {
@@ -100,11 +101,12 @@ function docker_build_child {
100101}
101102
102103function get_jenkins_url {
103- if [ -z " ${DOCKER_HOST} " ]; then
104+ docker_host=" ${DOCKER_HOST:- } "
105+ if [ -z " ${docker_host} " ]; then
104106 DOCKER_IP=localhost
105107 else
106108 # shellcheck disable=SC2001
107- DOCKER_IP=$( echo " $DOCKER_HOST " | sed -e ' s|tcp://\(.*\):[0-9]*|\1|' )
109+ DOCKER_IP=$( echo " ${docker_host} " | sed -e ' s|tcp://\(.*\):[0-9]*|\1|' )
108110 fi
109111 echo " http://$DOCKER_IP :$( docker port " $( get_sut_container_name) " 8080 | cut -d: -f2) "
110112}
@@ -113,6 +115,17 @@ function get_jenkins_password {
113115 docker exec " $( get_sut_container_name) " cat /var/jenkins_home/secrets/initialAdminPassword
114116}
115117
118+ function get_targets_from_jenkinsfile {
119+ sed -n ' /def images = \[/,/]/p' Jenkinsfile ` # retrieve images array from Jenkinsfile` \
120+ | grep " '" ` # keep only its items` \
121+ | tr -d " ', " ` # cleanup output` \
122+ | sort ` # ensure constant output sort`
123+ }
124+
125+ function get_default_docker_bake_targets {
126+ make --silent show | jq -r ' .target | keys[]' | sort
127+ }
128+
116129function test_url {
117130 run curl --user " admin:$( get_jenkins_password) " --output /dev/null --silent --head --fail --connect-timeout 30 --max-time 60 " $( get_jenkins_url) $1 "
118131 if [ " $status " -eq 0 ]; then
You can’t perform that action at this time.
0 commit comments