Wrap vars in script call to avoid insecure call detection

This commit is contained in:
2025-06-04 11:32:42 +02:00
parent ef3e493a39
commit ff8ca3331d
2 changed files with 39 additions and 0 deletions

View File

@@ -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}
"""
}
}

View File

@@ -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}"
}
}
}