Skip to content

Commit 9d24f72

Browse files
committed
Merge branch 'main' into develop-v2
# Conflicts: # imagetool/pom.xml # installer/pom.xml # pom.xml # tests/pom.xml
2 parents 1333ec4 + 28b5aec commit 9d24f72

File tree

17 files changed

+201
-57
lines changed

17 files changed

+201
-57
lines changed

.github/workflows/create-release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
#
4+
name: Create Release
5+
run-name: Creating draft release for ${{ github.ref_name }}
6+
7+
on:
8+
push:
9+
tags:
10+
- 'release-*'
11+
12+
jobs:
13+
release_job:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- run: |
18+
mvn -B clean package
19+
- id: version
20+
run: echo "::set-output name=number::`echo "${{ github.ref_name }}" | sed 's/release-//'`"
21+
- env:
22+
GH_TOKEN: ${{ github.token }}
23+
run: |
24+
gh release create ${{ github.ref_name }} \
25+
--draft \
26+
--generate-notes \
27+
--title 'WebLogic Image Tool ${{ steps.version.outputs.number }}' \
28+
installer/target/imagetool.zip

.github/workflows/publish-github-pages.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2021, 2023, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
#
44
# Description
@@ -8,7 +8,10 @@ name: "PublishGitHubPages"
88

99
on:
1010
push:
11-
branches: [ main ]
11+
branches:
12+
- 'main'
13+
paths:
14+
- 'documentation/**'
1215
schedule:
1316
- cron: '15 3 * * 1'
1417

@@ -23,32 +26,19 @@ jobs:
2326

2427
steps:
2528
- name: Checkout main
26-
uses: actions/checkout@v2.3.4
29+
uses: actions/checkout@v3
2730
with:
2831
ref: main
29-
fetch-depth: 32
3032
path: main
3133

3234
- name: Checkout gh-pages
33-
uses: actions/checkout@v2.3.4
35+
uses: actions/checkout@v3
3436
with:
3537
ref: gh-pages
3638
path: gh-pages
3739
token: ${{ secrets.PUBLISH_SECRET }}
3840

39-
- name: Verify changes to documentation present
40-
id: change-check
41-
run: |
42-
cd $GITHUB_WORKSPACE/main
43-
X=`git diff HEAD~1 --name-only | { grep "^documentation" || test $? = 1; } | wc -l`
44-
if [ $X == "0" ]; then
45-
echo 'No changes to the documenation'
46-
else
47-
echo '::set-output name=DOCUMENTATION_CHANGED::true'
48-
fi
49-
5041
- name: Build and publish site
51-
if: ${{ steps.change-check.outputs.DOCUMENTATION_CHANGED == 'true' }}
5242
run: |
5343
curl -fL -o hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v0.82.0/hugo_0.82.0_Linux-64bit.tar.gz"
5444
tar -xf hugo.tar.gz

.github/workflows/sonar-branch.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
#
4+
name: Sonar Scan
5+
6+
on:
7+
push:
8+
branches:
9+
- 'main'
10+
- 'develop*'
11+
12+
jobs:
13+
sonar_scan:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
- name: Setup JDK 11
20+
uses: actions/setup-java@v3
21+
with:
22+
distribution: 'adopt'
23+
java-version: 11
24+
- name: Build and Test
25+
run: |
26+
mvn -B clean package
27+
- name: Sonar Scan
28+
run: |
29+
mvn -B sonar:sonar \
30+
-Dsonar.branch.name=main \
31+
-Dsonar.projectKey=oracle_weblogic-image-tool
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Jenkinsfile

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -162,40 +162,14 @@ pipeline {
162162
stage ('Sync') {
163163
when {
164164
branch 'main'
165-
anyOf {
166-
not { triggeredBy 'TimerTrigger' }
167-
tag 'release-*'
168-
}
165+
not { triggeredBy 'TimerTrigger' }
169166
}
170167
steps {
171168
build job: "wkt-sync",
172169
parameters: [ string(name: 'REPOSITORY', value: 'weblogic-image-tool') ],
173170
wait: true
174171
}
175172
}
176-
stage ('Create Draft Release') {
177-
when {
178-
tag 'release-*'
179-
}
180-
steps {
181-
script {
182-
env.TAG_VERSION_NUMBER = env.TAG_NAME.replaceAll('release-','').trim()
183-
}
184-
withCredentials([string(credentialsId: 'wkt-github-token', variable: 'GITHUB_API_TOKEN')]) {
185-
sh """
186-
mkdir gh-cli
187-
curl -sL https://github.com/cli/cli/releases/download/v2.28.0/gh_2.28.0_linux_amd64.tar.gz | tar xvzf - --strip-components=1 -C ./gh-cli
188-
echo '${GITHUB_API_TOKEN}' | ./gh-cli/bin/gh auth login --with-token
189-
./gh-cli/bin/gh release create ${TAG_NAME} \
190-
--draft \
191-
--generate-notes \
192-
--title 'WebLogic Image Tool ${TAG_VERSION_NUMBER}' \
193-
--repo https://github.com/oracle/weblogic-image-tool \
194-
installer/target/imagetool.zip
195-
"""
196-
}
197-
}
198-
}
199173
}
200174
}
201175

imagetool/src/main/java/com/oracle/weblogic/imagetool/builder/BuildCommand.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.nio.file.Paths;
1616
import java.util.ArrayList;
1717
import java.util.List;
18+
import java.util.Map;
1819
import java.util.Objects;
1920
import java.util.stream.Collectors;
2021
import java.util.stream.Stream;
@@ -98,6 +99,21 @@ public BuildCommand buildArg(String key, String value, boolean conceal) {
9899
return this;
99100
}
100101

102+
/**
103+
* Add multiple --build-arg key value pairs to the Docker build command.
104+
* @param keyValuePairs A map of key-value pairs to be used directly with the container image builder
105+
*/
106+
public BuildCommand buildArg(Map<String,String> keyValuePairs) {
107+
if (keyValuePairs == null || keyValuePairs.isEmpty()) {
108+
return this;
109+
}
110+
111+
for (Map.Entry<String,String> entry : keyValuePairs.entrySet()) {
112+
buildArg(entry.getKey(), entry.getValue());
113+
}
114+
return this;
115+
}
116+
101117
/**
102118
* Add a --network to the Docker build command.
103119
* @param value the Docker network to use

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.time.Duration;
1212
import java.time.Instant;
1313
import java.util.List;
14+
import java.util.Map;
1415
import java.util.Properties;
1516
import java.util.UUID;
1617
import java.util.regex.Matcher;
@@ -123,6 +124,7 @@ BuildCommand getInitialBuildCmd(String contextFolder) {
123124
.tag(imageTag)
124125
.network(buildNetwork)
125126
.pull(buildPull)
127+
.buildArg(buildArgs)
126128
.buildArg("http_proxy", httpProxyUrl, httpProxyUrl != null && httpProxyUrl.contains("@"))
127129
.buildArg("https_proxy", httpsProxyUrl, httpsProxyUrl != null && httpsProxyUrl.contains("@"))
128130
.buildArg("no_proxy", nonProxyHosts);
@@ -175,6 +177,12 @@ void initializeOptions() throws InvalidCredentialException, IOException, Invalid
175177
handleChown();
176178
handleAdditionalBuildCommands();
177179

180+
if (buildArgs != null) {
181+
for (String arg : buildArgs.keySet()) {
182+
dockerfileOptions.buildArgs(arg);
183+
}
184+
}
185+
178186
if (kubernetesTarget == KubernetesTarget.OPENSHIFT) {
179187
dockerfileOptions.setDomainGroupAsUser(true);
180188
// if the user did not set the OS user:group, make the default oracle:root, instead of oracle:oracle
@@ -408,6 +416,12 @@ public String buildId() {
408416
)
409417
KubernetesTarget kubernetesTarget = KubernetesTarget.DEFAULT;
410418

419+
@Option(
420+
names = {"--build-arg"},
421+
description = "Additional argument passed directly to the build engine."
422+
)
423+
Map<String,String> buildArgs;
424+
411425
@SuppressWarnings("unused")
412426
@Unmatched
413427
List<String> unmatchedOptions;

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/DockerfileOptions.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class DockerfileOptions {
6666
private MiddlewareInstall mwInstallers;
6767
private boolean domainGroupAsUser;
6868
private boolean usingBusybox;
69+
private List<String> buildArgs;
6970

7071
// WDT values
7172
private String wdtHome;
@@ -97,6 +98,7 @@ public DockerfileOptions(String buildId) {
9798
skipMiddlewareInstall = false;
9899
domainGroupAsUser = false;
99100
usingBusybox = false;
101+
buildArgs = new ArrayList<>();
100102

101103
javaHome = DEFAULT_JAVA_HOME;
102104
oracleHome = DEFAULT_ORACLE_HOME;
@@ -1119,4 +1121,23 @@ public DockerfileOptions usingBusybox(boolean value) {
11191121
usingBusybox = value;
11201122
return this;
11211123
}
1124+
1125+
/**
1126+
* Used by mustache template to retrieve variable names for ARG in Dockerfile.
1127+
* @return list of variable names
1128+
*/
1129+
@SuppressWarnings("unused")
1130+
public List<String> buildArgs() {
1131+
return buildArgs;
1132+
}
1133+
1134+
/**
1135+
* Add ARG statements to the Dockerfile.
1136+
* @param variableName an ARG name.
1137+
* @return this
1138+
*/
1139+
public DockerfileOptions buildArgs(String variableName) {
1140+
buildArgs.add(variableName);
1141+
return this;
1142+
}
11221143
}

imagetool/src/main/resources/docker-files/Create_Image.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#
44

55
FROM {{baseImage}} as os_update
6+
{{#buildArgs}}ARG {{{.}}}
7+
{{/buildArgs}}
68
LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
79
USER root
810
{{#initialBuildCommands}}
@@ -29,7 +31,8 @@ USER root
2931
{{/isWdtEnabled}}
3032

3133
FROM os_update as final_build
32-
34+
{{#buildArgs}}ARG {{{.}}}
35+
{{/buildArgs}}
3336
ENV ORACLE_HOME={{{oracle_home}}} \
3437
LD_LIBRARY_PATH={{{oracle_home}}}/oracle_common/adr:$LD_LIBRARY_PATH \
3538
{{#installJava}}

imagetool/src/main/resources/docker-files/Rebase_Image.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
{{#isRebaseToTarget}}
66
FROM {{sourceImage}} as source_image
77
FROM {{targetImage}} as final_build
8+
{{#buildArgs}}ARG {{{.}}}
9+
{{/buildArgs}}
810

911
ENV DOMAIN_HOME={{{domain_home}}}
1012
LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
@@ -38,7 +40,8 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
3840
{{/installMiddleware}}
3941

4042
FROM os_update as final_build
41-
43+
{{#buildArgs}}ARG {{{.}}}
44+
{{/buildArgs}}
4245
ENV ORACLE_HOME={{{oracle_home}}} \
4346
LD_LIBRARY_PATH={{{oracle_home}}}/oracle_common/adr:$LD_LIBRARY_PATH \
4447
{{#installJava}}

imagetool/src/main/resources/docker-files/Update_Image.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
{{/isWdtEnabled}}
88

99
FROM {{baseImage}} as final_build
10+
{{#buildArgs}}ARG {{{.}}}
11+
{{/buildArgs}}
1012
USER root
1113

1214
ENV OPATCH_NO_FUSER=true

0 commit comments

Comments
 (0)