Security Center integrates with Jenkins to scan container images automatically during each build. Install the sas-jenkins-plugin plug-in, then configure a Jenkinsfile to trigger image scanning when your pipeline runs.
This guide covers the following steps:
Download the plug-in from the Security Center console
Install the plug-in on Jenkins
Configure image scanning in your Jenkins Pipeline project
Prerequisites
Before you begin, ensure that you have:
Jenkins 1.625.3 or later
Access to the Security Center console
An Alibaba Cloud AccessKey ID and AccessKey Secret
A Jenkins Pipeline project
Download the CI/CD plug-in
Log on to the Security Center console. In the top navigation bar, select the region of the asset you want to manage. The supported regions are China and Outside China.
In the left-side navigation pane, choose Protection Configuration > Container Protection > CI/CD Integration Settings.
Click Integration Configuration.
In the Integration Configuration panel, click Download Plug-in in the upper-right corner.
The plug-in is downloaded as an HPI file named sas-jenkins-plugin.
Install the CI/CD plug-in on Jenkins
Log on to Jenkins.
In the left-side navigation pane, click Manage Jenkins.
On the Manage Jenkins page, click Manage Plugins.
On the Manage Plugins page, click the Advanced tab.
In the Upload Plugin section, click Choose File and select the
sas-jenkins-pluginHPI file.Click Upload.
Restart Jenkins after installation. The plug-in does not take effect until Jenkins restarts.
Configure image scanning
Log on to Jenkins.
Find the Jenkins Pipeline project whose images you want to scan and click the project name.
In the left-side navigation pane, click Configure.
In the Pipeline section, add the
sas()step to your Jenkinsfile. Choose one of the following examples based on your pipeline type.Scripted Pipeline
node { sas(accessKeyId: '$AK', accessKeySecret: '$SK', token: '$TOKEN', imageId: '$IMAGE', domain: '$DOMAIN', registryUrl: '$REGISTRY_URL', registryUsername: '$REGISTRY_USERNAME', registryPwd: '$REGISTRY_PWD') }Declarative Pipeline
pipeline { agent any environment { ACCESS_KEY_ID = '$AK' ACCESS_KEY_SECRET = '$SK' IMAGE_ID = '$IMAGE' TOKEN = '$TOKEN' DOMAIN = '$DOMAIN' REGISTRY_URL = null REGISTRY_USERNAME = null REGISTRY_PWD = null } stages { stage('Build') { steps { sas(accessKeyId: env.ACCESS_KEY_ID, accessKeySecret: env.ACCESS_KEY_SECRET, imageId: env.IMAGE_ID, token: env.TOKEN, domain: env.DOMAIN, registryUrl: env.REGISTRY_URL, registryUsername: env.REGISTRY_USERNAME, registryPwd: env.REGISTRY_PWD) } } } }Click Save.
Security Center scans images in the project for risks each time you trigger a build.
What's next
View image scanning results on the Container tab of the Assets page in the Security Center console. For more information, see View image scan results.