Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9f3f0ad

Browse files
committedApr 10, 2023
Update the role and some modifications
Signed-off-by: Zelin Hao <zelinhao@amazon.com>
1 parent c2b189d commit 9f3f0ad

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed
 

‎jenkins/packer/packer-build.jenkinsfile

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
lib = library(identifier: 'jenkins@3.0.0', retriever: modernSCM([
2+
$class: 'GitSCMSource',
3+
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
4+
]))
5+
16
pipeline {
27
options {
38
timeout(time: 4, unit: 'HOURS')
@@ -6,7 +11,6 @@ pipeline {
611
docker {
712
label 'Jenkins-Agent-Ubuntu2004-X64-M52xlarge-Docker-Builder'
813
image 'opensearchstaging/ci-runner:ubuntu2004-x64-docker-buildx0.6.3-qemu5.0-awscli1.22-jdk11-v2'
9-
args '-u root -v /var/run/docker.sock:/var/run/docker.sock'
1014
alwaysPull true
1115
}
1216
}
@@ -40,20 +44,23 @@ pipeline {
4044
checkout([$class: 'GitSCM', branches: [[name: PACKER_BUILD_GIT_REPOSITORY_REFERENCE ]], userRemoteConfigs: [[url: PACKER_BUILD_GIT_REPOSITORY ]]])
4145
def packer_jenkins_agent_json = readJSON file: "./packer/$PACKER_AGENT_JSON_NAME"
4246
withCredentials([
43-
string(credentialsId: "jenkins-agent-vpc-id", variable: 'vpc_id'),
44-
string(credentialsId: "jenkins-agent-subnet-id", variable: 'subnet_id'),
45-
string(credentialsId: "jenkins-agent-sg-id", variable: 'sg_id')
47+
string(credentialsId: 'jenkins-agent-vpc-id', variable: 'vpc_id'),
48+
string(credentialsId: 'jenkins-agent-subnet-id', variable: 'subnet_id'),
49+
string(credentialsId: 'jenkins-agent-sg-id', variable: 'sg_id')
4650
]){
4751
packer_jenkins_agent_json["variables"]["build-vpc"] = vpc_id
4852
packer_jenkins_agent_json["variables"]["build-subnet"] = subnet_id
4953
packer_jenkins_agent_json["variables"]["build-secgrp"] = sg_id
5054
}
51-
writeJSON file: "./packer/$PACKER_AGENT_JSON_NAME", json: packer_jenkins_agent_json, pretty: 2
55+
def PACKER_AGENT_JSON_NAME_SUBSTITUTE = "SUBSTITUTE_" + "$PACKER_AGENT_JSON_NAME"
56+
print("$PACKER_AGENT_JSON_NAME_SUBSTITUTE")
57+
writeJSON file: "./packer/$PACKER_AGENT_JSON_NAME_SUBSTITUTE", json: packer_jenkins_agent_json, pretty: 2
5258

53-
//Start to build packer
59+
// Start to build packer
5460
withCredentials([string(credentialsId: 'jenkins-aws-account-public', variable: 'AWS_ACCOUNT_PUBLIC')]) {
55-
withAWS(role: 'opensearch-bundle', roleAccount: "${AWS_ACCOUNT_PUBLIC}", duration: 900, roleSessionName: 'jenkins-session') {
56-
sh ("packer build ./packer/$PACKER_AGENT_JSON_NAME")
61+
withAWS(role: 'opensearch-packer', roleAccount: "${AWS_ACCOUNT_PUBLIC}", duration: 900, roleSessionName: 'jenkins-session') {
62+
// sh ("packer build ./packer/$PACKER_AGENT_JSON_NAME_SUBSTITUTE")
63+
sh ("ls ./packer/")
5764
}
5865
}
5966

@@ -62,7 +69,7 @@ pipeline {
6269
post() {
6370
always {
6471
script {
65-
cleanWs disableDeferredWipeout: true, deleteDirs: true
72+
postCleanup()
6673
}
6774
}
6875
}

‎tests/jenkins/TestPackerBuild.groovy

-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ class TestPackerBuild extends BuildPipelineTest {
7777
closure.delegate = delegate
7878
return helper.callClosure(closure)
7979
})
80-
helper.addShMock("cat $packerAgentJsonName | grep \"404: Not Found\"") { script ->
81-
return [stdout: "", exitValue: 1]
82-
}
8380
helper.addShMock("packer build ./packer/$packerAgentJsonName") { script ->
8481
return [stdout: "", exitValue: 0]
8582
}

0 commit comments

Comments
 (0)
Please sign in to comment.