Wrap vars in script call to avoid insecure call detection
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
def call(Map args = [:]) {
|
||||||
|
script {
|
||||||
|
if (!args.imageName || !args.dockerfile || !args.context) {
|
||||||
|
error "dockerBuild requires imageName, dockerfile, and context arguments"
|
||||||
|
}
|
||||||
|
|
||||||
|
def imageName = args.imageName
|
||||||
|
def dockerfile = args.dockerfile
|
||||||
|
def context = args.context
|
||||||
|
|
||||||
|
echo "Building Docker image: ${imageName}"
|
||||||
|
sh """
|
||||||
|
docker build -t ${imageName} -f ${dockerfile} ${context}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
def call(Map args = [:]) {
|
||||||
|
script {
|
||||||
|
if (!args.imageName || !args.registry || !args.credentialsId) {
|
||||||
|
error "dockerPush requires imageName, registry, and credentialsId arguments"
|
||||||
|
}
|
||||||
|
|
||||||
|
def imageName = args.imageName
|
||||||
|
def registry = args.registry
|
||||||
|
def credentialsId = args.credentialsId
|
||||||
|
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: credentialsId,
|
||||||
|
usernameVariable: 'DOCKER_USER',
|
||||||
|
passwordVariable: 'DOCKER_PASS'
|
||||||
|
)]) {
|
||||||
|
echo "Logging into Docker registry: ${registry}"
|
||||||
|
sh "echo \$DOCKER_PASS | docker login ${registry} -u \$DOCKER_USER --password-stdin"
|
||||||
|
|
||||||
|
echo "Pushing Docker image: ${imageName}"
|
||||||
|
sh "docker push ${imageName}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user