Question: how to refer to docker image built in a previous CI step?

Hello, my automation configuration contains sevaral steps. One of them builds a docker image with custom image:tag (includes branch name). Next step should use that docker image. However, I haven't found a way to pass docker image name to `container( image = ... )`.

I tried env variables and DSL functions/variables, but neither of it have worked.

How can I define container image in runtime?

job("build and test") {
docker {
beforeBuildScript {
// create an env variable BRANCH
content = """
export BRANCH=${'$'}(echo ${'$'}JB_SPACE_GIT_BRANCH | cut -d'/' -f 3)
"""
}
build {}

push(rootImage) {
tags ("\$BRANCH")
}
}
// what to place here?
// neither of following worked:
// $rootImage:$BRANCH
// $rootImage:\$BRANCH
// $rootImage:${'$'}BRANCH
container(displayName = "run tests", image = "$rootImage:??????????????????")) {
shellScript {
content = """
pip install pytest-cov
pytest --show-capture stderr --cov=. --cov-report term:skip-covered
"""
}
}
}
1
4 comments

Artem - hi,

Thank you for your question.

Now there is no way to use the exact version of the built image, it's possible only to reference it by a static tag like 'release'. But we plan to support this behavior in the future so please feel free to upvote SPACE-13318 Using Automation environment variables in container definitions and subscribe for further updates.

Margarita Kolotilova
JetBrains
http://www.jetbrains.com
The Drive to Develop

0

Margarita Kolotilova I had asked the responder on the issue for SPACE-13318 and got no response. I looked into the user and found that they have been banned? Is there a way to assign SPACE-13318 to someone? I'd love to move projects to space, but I can't without being able to use images from previous steps.

Issue: https://youtrack.jetbrains.com/issue/SPACE-13318

0

Andy Honeycutt, we'll take a look at this issue and provide you with the update there. Thank you!

0

Pavel Boger That's great, thanks so much!

0

Please sign in to leave a comment.